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);
128 /// Provides methods to print log messages to the Tizen logging system.
130 [EditorBrowsable(EditorBrowsableState.Never)]
131 public class InternalLog
134 /// Prints a log message with the VERBOSE priority.
136 /// <since_tizen> 3 </since_tizen>
137 /// <param name="tag">The tag name of the log message.</param>
138 /// <param name="message">The log message to print.</param>
139 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
140 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
141 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
142 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
144 // For internal dlog APIs, Verbose level log is disabled
145 // Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
149 /// Prints a log message with the DEBUG priority.
151 /// <since_tizen> 3 </since_tizen>
152 /// <param name="tag">The tag name of the log message.</param>
153 /// <param name="message">The log message to print.</param>
154 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
155 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
156 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
157 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
159 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
163 /// Prints a log message with the INFO priority.
165 /// <since_tizen> 3 </since_tizen>
166 /// <param name="tag">The tag name of the log message.</param>
167 /// <param name="message">The log message to print.</param>
168 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
169 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
170 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
171 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
173 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
177 /// Prints a log message with the WARNING priority.
179 /// <since_tizen> 3 </since_tizen>
180 /// <param name="tag">The tag name of the log message.</param>
181 /// <param name="message">The log message to print.</param>
182 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
183 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
184 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
185 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
187 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
191 /// Prints a log message with the ERROR priority.
193 /// <since_tizen> 3 </since_tizen>
194 /// <param name="tag">The tag name of the log message.</param>
195 /// <param name="message">The log message to print.</param>
196 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
197 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
198 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
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);
205 /// Prints a log message with the FATAL priority.
207 /// <since_tizen> 3 </since_tizen>
208 /// <param name="tag">The tag name of the log message.</param>
209 /// <param name="message">The log message to print.</param>
210 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
211 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
212 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
213 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
215 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
218 static void Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
220 if (String.IsNullOrEmpty(file))
222 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s", message);
226 Uri f = new Uri("file://" + file);
227 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > %s", Path.GetFileName(f.AbsolutePath), func, line, message);
233 /// Provides methods to print log messages to the Tizen logging system.
235 [EditorBrowsable(EditorBrowsableState.Never)]
236 public class SecureLog
239 /// Prints a log message with the VERBOSE priority.
241 /// <since_tizen> 3 </since_tizen>
242 /// <param name="tag">The tag name of the log message.</param>
243 /// <param name="message">The log message to print.</param>
244 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
245 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
246 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
247 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
249 // For internal dlog APIs, Verbose level log is disabled
250 // Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
254 /// Prints a log message with the DEBUG priority.
256 /// <since_tizen> 3 </since_tizen>
257 /// <param name="tag">The tag name of the log message.</param>
258 /// <param name="message">The log message to print.</param>
259 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
260 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
261 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
262 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
264 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
268 /// Prints a log message with the INFO priority.
270 /// <since_tizen> 3 </since_tizen>
271 /// <param name="tag">The tag name of the log message.</param>
272 /// <param name="message">The log message to print.</param>
273 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
274 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
275 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
276 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
278 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
282 /// Prints a log message with the WARNING priority.
284 /// <since_tizen> 3 </since_tizen>
285 /// <param name="tag">The tag name of the log message.</param>
286 /// <param name="message">The log message to print.</param>
287 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
288 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
289 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
290 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
292 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
296 /// Prints a log message with the ERROR priority.
298 /// <since_tizen> 3 </since_tizen>
299 /// <param name="tag">The tag name of the log message.</param>
300 /// <param name="message">The log message to print.</param>
301 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
302 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
303 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
304 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
306 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
310 /// Prints a log message with the FATAL priority.
312 /// <since_tizen> 3 </since_tizen>
313 /// <param name="tag">The tag name of the log message.</param>
314 /// <param name="message">The log message to print.</param>
315 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
316 /// <param name="func">The function name of the caller function. This argument will be set automatically by the compiler.</param>
317 /// <param name="line">The line number of the calling position. This argument will be set automatically by the compiler.</param>
318 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
320 Print(Interop.Dlog.LogID.LOG_ID_MAIN, Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
323 static void Print(Interop.Dlog.LogID log_id, Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
325 #if !DISABLE_SECURELOG
326 if (String.IsNullOrEmpty(file))
328 Interop.Dlog.InternalPrint(log_id, priority, tag, "[SECURE_LOG] %s", message);
332 Uri f = new Uri("file://" + file);
333 Interop.Dlog.InternalPrint(log_id, priority, tag, "%s: %s(%d) > [SECURE_LOG] %s", Path.GetFileName(f.AbsolutePath), func, line, message);