1 // Copyright 2016 by Samsung Electronics, Inc.,
3 // This software is the confidential and proprietary information
4 // of Samsung Electronics, Inc. ("Confidential Information"). You
5 // shall not disclose such Confidential Information and shall use
6 // it only in accordance with the terms of the license agreement
7 // you entered into with Samsung.
11 using System.Runtime.CompilerServices;
16 /// Provides methods to print log messages to Tizen logging system.
18 public static class Log
21 /// Prints a log message with the DEBUG priority.
23 /// <param name="tag">The tag name of the log message.</param>
24 /// <param name="message">The log message to print.</param>
25 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
26 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
27 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
28 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
30 Print(Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
34 /// Prints a log message with the VERBOSE priority.
36 /// <param name="tag">The tag name of the log message.</param>
37 /// <param name="message">The log message to print.</param>
38 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
39 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
40 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
41 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
43 Print(Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
47 /// Prints a log message with the INFO priority.
49 /// <param name="tag">The tag name of the log message.</param>
50 /// <param name="message">The log message to print.</param>
51 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
52 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
53 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
54 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
56 Print(Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
60 /// Prints a log message with the WARNING priority.
62 /// <param name="tag">The tag name of the log message.</param>
63 /// <param name="message">The log message to print.</param>
64 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
65 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
66 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
67 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
69 Print(Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
73 /// Prints a log message with the ERROR priority.
75 /// <param name="tag">The tag name of the log message.</param>
76 /// <param name="message">The log message to print.</param>
77 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
78 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
79 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
80 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
82 Print(Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
86 /// Prints a log message with the FATAL priority.
88 /// <param name="tag">The tag name of the log message.</param>
89 /// <param name="message">The log message to print.</param>
90 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
91 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
92 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
93 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
95 Print(Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
98 private static void Print(Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
100 if (String.IsNullOrEmpty(file))
102 Interop.Dlog.Print(priority, tag, "%s", message);
106 Uri f = new Uri("file://" + file);
107 Interop.Dlog.Print(priority, tag, "%s: %s(%d) > %s", Path.GetFileName(f.AbsolutePath), func, line, message);