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.
26 /// Depending on products, some priorities (e.g., Vervose and Debug) can be disabled by default to prevent too many logs.
28 /// <since_tizen> 3 </since_tizen>
32 /// Prints a log message with the VERBOSE priority.
34 /// <since_tizen> 3 </since_tizen>
35 /// <param name="tag">The tag name of the log message.</param>
36 /// <param name="message">The log message to print.</param>
37 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
38 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
39 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
40 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
42 Print(Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
46 /// Prints a log message with the DEBUG priority.
48 /// <since_tizen> 3 </since_tizen>
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 the caller function. This argument will be set automatically by the compiler.</param>
53 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
54 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
56 Print(Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
60 /// Prints a log message with the INFO priority.
62 /// <since_tizen> 3 </since_tizen>
63 /// <param name="tag">The tag name of the log message.</param>
64 /// <param name="message">The log message to print.</param>
65 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
66 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
67 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
68 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
70 Print(Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
74 /// Prints a log message with the WARNING priority.
76 /// <since_tizen> 3 </since_tizen>
77 /// <param name="tag">The tag name of the log message.</param>
78 /// <param name="message">The log message to print.</param>
79 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
80 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
81 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
82 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
84 Print(Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
88 /// Prints a log message with the ERROR priority.
90 /// <since_tizen> 3 </since_tizen>
91 /// <param name="tag">The tag name of the log message.</param>
92 /// <param name="message">The log message to print.</param>
93 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
94 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
95 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
96 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
98 Print(Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
102 /// Prints a log message with the FATAL priority.
104 /// <since_tizen> 3 </since_tizen>
105 /// <param name="tag">The tag name of the log message.</param>
106 /// <param name="message">The log message to print.</param>
107 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
108 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
109 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
110 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
112 Print(Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
115 static void Print(Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
117 if (String.IsNullOrEmpty(file))
119 Interop.Dlog.Print(priority, tag, "%s", message);
123 Uri f = new Uri("file://" + file);
124 Interop.Dlog.Print(priority, tag, "%s: %s(%d) > %s", Path.GetFileName(f.AbsolutePath), func, line, message);
130 /// Provides methods to print log messages to the Tizen logging system.
132 /// <since_tizen> 3 </since_tizen>
133 [EditorBrowsable(EditorBrowsableState.Never)]
134 public class InternalLog
137 /// Prints a log message with the VERBOSE priority.
139 /// <since_tizen> 3 </since_tizen>
140 /// <param name="tag">The tag name of the log message.</param>
141 /// <param name="message">The log message to print.</param>
142 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
143 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
144 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
145 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
147 // For internal dlog APIs, Verbose level log is disabled
148 // Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
152 /// Prints a log message with the DEBUG priority.
154 /// <since_tizen> 3 </since_tizen>
155 /// <param name="tag">The tag name of the log message.</param>
156 /// <param name="message">The log message to print.</param>
157 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
158 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
159 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
160 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
162 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
166 /// Prints a log message with the INFO priority.
168 /// <since_tizen> 3 </since_tizen>
169 /// <param name="tag">The tag name of the log message.</param>
170 /// <param name="message">The log message to print.</param>
171 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
172 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
173 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
174 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
176 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
180 /// Prints a log message with the WARNING priority.
182 /// <since_tizen> 3 </since_tizen>
183 /// <param name="tag">The tag name of the log message.</param>
184 /// <param name="message">The log message to print.</param>
185 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
186 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
187 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
188 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
190 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
194 /// Prints a log message with the ERROR priority.
196 /// <since_tizen> 3 </since_tizen>
197 /// <param name="tag">The tag name of the log message.</param>
198 /// <param name="message">The log message to print.</param>
199 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
200 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
201 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
202 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
204 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
208 /// Prints a log message with the FATAL priority.
210 /// <since_tizen> 3 </since_tizen>
211 /// <param name="tag">The tag name of the log message.</param>
212 /// <param name="message">The log message to print.</param>
213 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
214 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
215 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
216 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
218 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
221 static void Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
223 if (String.IsNullOrEmpty(file))
225 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s", message);
229 Uri f = new Uri("file://" + file);
230 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > %s", Path.GetFileName(f.AbsolutePath), func, line, message);
236 /// Provides methods to print log messages to the Tizen logging system.
238 /// <since_tizen> 3 </since_tizen>
239 [EditorBrowsable(EditorBrowsableState.Never)]
240 public class SecureLog
243 /// Prints a log message with the VERBOSE priority.
245 /// <since_tizen> 3 </since_tizen>
246 /// <param name="tag">The tag name of the log message.</param>
247 /// <param name="message">The log message to print.</param>
248 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
249 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
250 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
251 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
253 // For internal dlog APIs, Verbose level log is disabled
254 // Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
258 /// Prints a log message with the DEBUG priority.
260 /// <since_tizen> 3 </since_tizen>
261 /// <param name="tag">The tag name of the log message.</param>
262 /// <param name="message">The log message to print.</param>
263 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
264 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
265 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
266 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
268 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
272 /// Prints a log message with the INFO priority.
274 /// <since_tizen> 3 </since_tizen>
275 /// <param name="tag">The tag name of the log message.</param>
276 /// <param name="message">The log message to print.</param>
277 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
278 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
279 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
280 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
282 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
286 /// Prints a log message with the WARNING priority.
288 /// <since_tizen> 3 </since_tizen>
289 /// <param name="tag">The tag name of the log message.</param>
290 /// <param name="message">The log message to print.</param>
291 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
292 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
293 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
294 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
296 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
300 /// Prints a log message with the ERROR priority.
302 /// <since_tizen> 3 </since_tizen>
303 /// <param name="tag">The tag name of the log message.</param>
304 /// <param name="message">The log message to print.</param>
305 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
306 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
307 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
308 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
310 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
314 /// Prints a log message with the FATAL priority.
316 /// <since_tizen> 3 </since_tizen>
317 /// <param name="tag">The tag name of the log message.</param>
318 /// <param name="message">The log message to print.</param>
319 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
320 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
321 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
322 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
324 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
327 static void Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
329 #if !DISABLE_SECURELOG
330 if (String.IsNullOrEmpty(file))
332 Interop.Dlog.InternalPrint(log_id, priority, tag, "[SECURE_LOG] %s", message);
336 Uri f = new Uri("file://" + file);
337 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > [SECURE_LOG] %s", Path.GetFileName(f.AbsolutePath), func, line, message);