2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Runtime.CompilerServices;
20 using System.ComponentModel;
25 /// Provides methods to print log messages to the Tizen logging system.
30 /// Prints a log message with the VERBOSE priority.
32 /// <since_tizen> 3 </since_tizen>
33 /// <param name="tag">The tag name of the log message.</param>
34 /// <param name="message">The log message to print.</param>
35 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
36 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
37 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
38 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
40 Print(Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
44 /// Prints a log message with the DEBUG priority.
46 /// <since_tizen> 3 </since_tizen>
47 /// <param name="tag">The tag name of the log message.</param>
48 /// <param name="message">The log message to print.</param>
49 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
50 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
51 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
52 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
54 Print(Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
58 /// Prints a log message with the INFO priority.
60 /// <since_tizen> 3 </since_tizen>
61 /// <param name="tag">The tag name of the log message.</param>
62 /// <param name="message">The log message to print.</param>
63 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
64 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
65 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
66 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
68 Print(Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
72 /// Prints a log message with the WARNING priority.
74 /// <since_tizen> 3 </since_tizen>
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 the caller function. This argument will be set automatically by the compiler.</param>
79 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
80 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
82 Print(Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
86 /// Prints a log message with the ERROR priority.
88 /// <since_tizen> 3 </since_tizen>
89 /// <param name="tag">The tag name of the log message.</param>
90 /// <param name="message">The log message to print.</param>
91 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
92 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
93 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
94 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
96 Print(Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
100 /// Prints a log message with the FATAL priority.
102 /// <since_tizen> 3 </since_tizen>
103 /// <param name="tag">The tag name of the log message.</param>
104 /// <param name="message">The log message to print.</param>
105 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
106 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
107 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
108 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
110 Print(Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
113 static void Print(Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
115 if (String.IsNullOrEmpty(file))
117 Interop.Dlog.Print(priority, tag, "%s", message);
121 Uri f = new Uri("file://" + file);
122 Interop.Dlog.Print(priority, tag, "%s: %s(%d) > %s", Path.GetFileName(f.AbsolutePath), func, line, message);
127 [EditorBrowsable(EditorBrowsableState.Never)]
128 public class InternalLog
130 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
132 // For internal dlog APIs, Verbose level log is disabled
133 // Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
136 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
138 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
141 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
143 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
146 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
148 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
151 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
153 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
156 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
158 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
161 static void Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
163 if (String.IsNullOrEmpty(file))
165 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s", message);
169 Uri f = new Uri("file://" + file);
170 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > %s", Path.GetFileName(f.AbsolutePath), func, line, message);
175 [EditorBrowsable(EditorBrowsableState.Never)]
176 public class SecureLog
178 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
180 // For internal dlog APIs, Verbose level log is disabled
181 // Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
184 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
186 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
189 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
191 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
194 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
196 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
199 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
201 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
204 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
206 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
209 static void Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
211 #if !DISABLE_SECURELOG
212 if (String.IsNullOrEmpty(file))
214 Interop.Dlog.InternalPrint(log_id, priority, tag, "[SECURE_LOG] %s", message);
218 Uri f = new Uri("file://" + file);
219 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > [SECURE_LOG] %s", Path.GetFileName(f.AbsolutePath), func, line, message);