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.
27 /// <since_tizen> 3 </since_tizen>
31 /// Prints a log message with the VERBOSE priority.
33 /// <since_tizen> 3 </since_tizen>
34 /// <param name="tag">The tag name of the log message.</param>
35 /// <param name="message">The log message to print.</param>
36 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
37 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
38 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
39 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
41 Print(Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
45 /// Prints a log message with the DEBUG priority.
47 /// <since_tizen> 3 </since_tizen>
48 /// <param name="tag">The tag name of the log message.</param>
49 /// <param name="message">The log message to print.</param>
50 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
51 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
52 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
53 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
55 Print(Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
59 /// Prints a log message with the INFO priority.
61 /// <since_tizen> 3 </since_tizen>
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 the caller function. This argument will be set automatically by the compiler.</param>
66 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
67 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
69 Print(Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
73 /// Prints a log message with the WARNING priority.
75 /// <since_tizen> 3 </since_tizen>
76 /// <param name="tag">The tag name of the log message.</param>
77 /// <param name="message">The log message to print.</param>
78 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
79 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
80 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
81 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
83 Print(Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
87 /// Prints a log message with the ERROR priority.
89 /// <since_tizen> 3 </since_tizen>
90 /// <param name="tag">The tag name of the log message.</param>
91 /// <param name="message">The log message to print.</param>
92 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
93 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
94 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
95 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
97 Print(Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
101 /// Prints a log message with the FATAL priority.
103 /// <since_tizen> 3 </since_tizen>
104 /// <param name="tag">The tag name of the log message.</param>
105 /// <param name="message">The log message to print.</param>
106 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
107 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
108 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
109 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
111 Print(Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
114 static void Print(Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
116 if (String.IsNullOrEmpty(file))
118 Interop.Dlog.Print(priority, tag, "%s", message);
122 Uri f = new Uri("file://" + file);
123 Interop.Dlog.Print(priority, tag, "%s: %s(%d) > %s", Path.GetFileName(f.AbsolutePath), func, line, message);
129 /// Provides methods to print log messages to the Tizen logging system.
131 /// <since_tizen> 3 </since_tizen>
132 [EditorBrowsable(EditorBrowsableState.Never)]
133 public class InternalLog
136 /// Prints a log message with the VERBOSE priority.
138 /// <since_tizen> 3 </since_tizen>
139 /// <param name="tag">The tag name of the log message.</param>
140 /// <param name="message">The log message to print.</param>
141 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
142 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
143 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
144 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
146 // For internal dlog APIs, Verbose level log is disabled
147 // Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
151 /// Prints a log message with the DEBUG priority.
153 /// <since_tizen> 3 </since_tizen>
154 /// <param name="tag">The tag name of the log message.</param>
155 /// <param name="message">The log message to print.</param>
156 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
157 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
158 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
159 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
161 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
165 /// Prints a log message with the INFO priority.
167 /// <since_tizen> 3 </since_tizen>
168 /// <param name="tag">The tag name of the log message.</param>
169 /// <param name="message">The log message to print.</param>
170 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
171 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
172 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
173 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
175 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
179 /// Prints a log message with the WARNING priority.
181 /// <since_tizen> 3 </since_tizen>
182 /// <param name="tag">The tag name of the log message.</param>
183 /// <param name="message">The log message to print.</param>
184 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
185 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
186 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
187 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
189 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
193 /// Prints a log message with the ERROR priority.
195 /// <since_tizen> 3 </since_tizen>
196 /// <param name="tag">The tag name of the log message.</param>
197 /// <param name="message">The log message to print.</param>
198 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
199 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
200 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
201 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
203 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
207 /// Prints a log message with the FATAL priority.
209 /// <since_tizen> 3 </since_tizen>
210 /// <param name="tag">The tag name of the log message.</param>
211 /// <param name="message">The log message to print.</param>
212 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
213 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
214 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
215 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
217 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
220 static void Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
222 if (String.IsNullOrEmpty(file))
224 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s", message);
228 Uri f = new Uri("file://" + file);
229 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > %s", Path.GetFileName(f.AbsolutePath), func, line, message);
235 /// Provides methods to print log messages to the Tizen logging system.
237 /// <since_tizen> 3 </since_tizen>
238 [EditorBrowsable(EditorBrowsableState.Never)]
239 public class SecureLog
242 /// Prints a log message with the VERBOSE priority.
244 /// <since_tizen> 3 </since_tizen>
245 /// <param name="tag">The tag name of the log message.</param>
246 /// <param name="message">The log message to print.</param>
247 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
248 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
249 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
250 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
252 // For internal dlog APIs, Verbose level log is disabled
253 // Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
257 /// Prints a log message with the DEBUG priority.
259 /// <since_tizen> 3 </since_tizen>
260 /// <param name="tag">The tag name of the log message.</param>
261 /// <param name="message">The log message to print.</param>
262 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
263 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
264 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
265 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
267 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
271 /// Prints a log message with the INFO priority.
273 /// <since_tizen> 3 </since_tizen>
274 /// <param name="tag">The tag name of the log message.</param>
275 /// <param name="message">The log message to print.</param>
276 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
277 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
278 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
279 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
281 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
285 /// Prints a log message with the WARNING priority.
287 /// <since_tizen> 3 </since_tizen>
288 /// <param name="tag">The tag name of the log message.</param>
289 /// <param name="message">The log message to print.</param>
290 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
291 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
292 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
293 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
295 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
299 /// Prints a log message with the ERROR priority.
301 /// <since_tizen> 3 </since_tizen>
302 /// <param name="tag">The tag name of the log message.</param>
303 /// <param name="message">The log message to print.</param>
304 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
305 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
306 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
307 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
309 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
313 /// Prints a log message with the FATAL priority.
315 /// <since_tizen> 3 </since_tizen>
316 /// <param name="tag">The tag name of the log message.</param>
317 /// <param name="message">The log message to print.</param>
318 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
319 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
320 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
321 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
323 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
326 static void Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
328 #if !DISABLE_SECURELOG
329 if (String.IsNullOrEmpty(file))
331 Interop.Dlog.InternalPrint(log_id, priority, tag, "[SECURE_LOG] %s", message);
335 Uri f = new Uri("file://" + file);
336 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > [SECURE_LOG] %s", Path.GetFileName(f.AbsolutePath), func, line, message);