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.
20 using System.Runtime.CompilerServices;
21 using System.ComponentModel;
26 /// Provides methods to print log messages to the Tizen logging system.
27 /// Depending on products, some priorities (e.g., Vervose and Debug) can be disabled by default to prevent too many logs.
29 /// <since_tizen> 3 </since_tizen>
33 /// Prints a log message with the VERBOSE priority.
35 /// <since_tizen> 3 </since_tizen>
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 the caller function. This argument will be set automatically by the compiler.</param>
40 /// <param name="line">The line number of the 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 DEBUG priority.
49 /// <since_tizen> 3 </since_tizen>
50 /// <param name="tag">The tag name of the log message.</param>
51 /// <param name="message">The log message to print.</param>
52 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
53 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
54 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
55 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
57 Print(Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
61 /// Prints a log message with the INFO priority.
63 /// <since_tizen> 3 </since_tizen>
64 /// <param name="tag">The tag name of the log message.</param>
65 /// <param name="message">The log message to print.</param>
66 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
67 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
68 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
69 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
71 Print(Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
75 /// Prints a log message with the WARNING priority.
77 /// <since_tizen> 3 </since_tizen>
78 /// <param name="tag">The tag name of the log message.</param>
79 /// <param name="message">The log message to print.</param>
80 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
81 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
82 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
83 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
85 Print(Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
89 /// Prints a log message with the ERROR priority.
91 /// <since_tizen> 3 </since_tizen>
92 /// <param name="tag">The tag name of the log message.</param>
93 /// <param name="message">The log message to print.</param>
94 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
95 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
96 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
97 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
99 Print(Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
103 /// Prints a log message with the FATAL priority.
105 /// <since_tizen> 3 </since_tizen>
106 /// <param name="tag">The tag name of the log message.</param>
107 /// <param name="message">The log message to print.</param>
108 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
109 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
110 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
111 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
113 Print(Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
116 static void Print(Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
118 if (String.IsNullOrEmpty(file))
120 Interop.Dlog.Print(priority, tag, "%s", message);
124 string[] fileslice = file.Split(new char[] { '\\', '/' });
125 string filename = fileslice.Last();
126 Interop.Dlog.Print(priority, tag, "%s: %s(%d) > %s", filename, func, line, message);
132 /// Provides methods to print log messages to the Tizen logging system.
134 /// <since_tizen> 3 </since_tizen>
135 [EditorBrowsable(EditorBrowsableState.Never)]
136 public class InternalLog
139 /// Prints a log message with the VERBOSE priority.
141 /// <since_tizen> 3 </since_tizen>
142 /// <param name="tag">The tag name of the log message.</param>
143 /// <param name="message">The log message to print.</param>
144 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
145 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
146 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
147 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
149 // For internal dlog APIs, Verbose level log is disabled
150 // Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
154 /// Prints a log message with the DEBUG priority.
156 /// <since_tizen> 3 </since_tizen>
157 /// <param name="tag">The tag name of the log message.</param>
158 /// <param name="message">The log message to print.</param>
159 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
160 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
161 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
162 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
164 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
168 /// Prints a log message with the INFO priority.
170 /// <since_tizen> 3 </since_tizen>
171 /// <param name="tag">The tag name of the log message.</param>
172 /// <param name="message">The log message to print.</param>
173 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
174 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
175 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
176 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
178 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
182 /// Prints a log message with the WARNING priority.
184 /// <since_tizen> 3 </since_tizen>
185 /// <param name="tag">The tag name of the log message.</param>
186 /// <param name="message">The log message to print.</param>
187 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
188 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
189 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
190 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
192 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
196 /// Prints a log message with the ERROR priority.
198 /// <since_tizen> 3 </since_tizen>
199 /// <param name="tag">The tag name of the log message.</param>
200 /// <param name="message">The log message to print.</param>
201 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
202 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
203 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
204 public static void Error(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_ERROR, tag, message, file, func, line);
210 /// Prints a log message with the FATAL priority.
212 /// <since_tizen> 3 </since_tizen>
213 /// <param name="tag">The tag name of the log message.</param>
214 /// <param name="message">The log message to print.</param>
215 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
216 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
217 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
218 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
220 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
223 static void Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
225 if (String.IsNullOrEmpty(file))
227 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s", message);
231 string[] fileslice = file.Split(new char[] { '\\', '/' });
232 string filename = fileslice.Last();
233 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > %s", filename, func, line, message);
239 /// Provides methods to print log messages to the Tizen logging system.
241 /// <since_tizen> 3 </since_tizen>
242 [EditorBrowsable(EditorBrowsableState.Never)]
243 public class SecureLog
246 /// Prints a log message with the VERBOSE priority.
248 /// <since_tizen> 3 </since_tizen>
249 /// <param name="tag">The tag name of the log message.</param>
250 /// <param name="message">The log message to print.</param>
251 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
252 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
253 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
254 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
256 // For internal dlog APIs, Verbose level log is disabled
257 // Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
261 /// Prints a log message with the DEBUG priority.
263 /// <since_tizen> 3 </since_tizen>
264 /// <param name="tag">The tag name of the log message.</param>
265 /// <param name="message">The log message to print.</param>
266 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
267 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
268 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
269 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
271 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
275 /// Prints a log message with the INFO priority.
277 /// <since_tizen> 3 </since_tizen>
278 /// <param name="tag">The tag name of the log message.</param>
279 /// <param name="message">The log message to print.</param>
280 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
281 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
282 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
283 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
285 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
289 /// Prints a log message with the WARNING priority.
291 /// <since_tizen> 3 </since_tizen>
292 /// <param name="tag">The tag name of the log message.</param>
293 /// <param name="message">The log message to print.</param>
294 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
295 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
296 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
297 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
299 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
303 /// Prints a log message with the ERROR priority.
305 /// <since_tizen> 3 </since_tizen>
306 /// <param name="tag">The tag name of the log message.</param>
307 /// <param name="message">The log message to print.</param>
308 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
309 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
310 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
311 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
313 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
317 /// Prints a log message with the FATAL priority.
319 /// <since_tizen> 3 </since_tizen>
320 /// <param name="tag">The tag name of the log message.</param>
321 /// <param name="message">The log message to print.</param>
322 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
323 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
324 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
325 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
327 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
330 static void Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
332 #if !DISABLE_SECURELOG
333 if (String.IsNullOrEmpty(file))
335 Interop.Dlog.InternalPrint(log_id, priority, tag, "[SECURE_LOG] %s", message);
339 string[] fileslice = file.Split(new char[] { '\\', '/' });
340 string filename = fileslice.Last();
341 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > %s", filename, func, line, message);