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;
24 /// Provides methods to print log messages to Tizen logging system.
26 public static class Log
29 /// Prints a log message with the DEBUG priority.
31 /// <param name="tag">The tag name of the log message.</param>
32 /// <param name="message">The log message to print.</param>
33 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
34 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
35 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
36 public static void Debug(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
38 Print(Interop.Dlog.LogPriority.DLOG_DEBUG, tag, message, file, func, line);
42 /// Prints a log message with the VERBOSE priority.
44 /// <param name="tag">The tag name of the log message.</param>
45 /// <param name="message">The log message to print.</param>
46 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
47 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
48 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
49 public static void Verbose(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
51 Print(Interop.Dlog.LogPriority.DLOG_VERBOSE, tag, message, file, func, line);
55 /// Prints a log message with the INFO priority.
57 /// <param name="tag">The tag name of the log message.</param>
58 /// <param name="message">The log message to print.</param>
59 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
60 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
61 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
62 public static void Info(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
64 Print(Interop.Dlog.LogPriority.DLOG_INFO, tag, message, file, func, line);
68 /// Prints a log message with the WARNING priority.
70 /// <param name="tag">The tag name of the log message.</param>
71 /// <param name="message">The log message to print.</param>
72 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
73 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
74 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
75 public static void Warn(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
77 Print(Interop.Dlog.LogPriority.DLOG_WARN, tag, message, file, func, line);
81 /// Prints a log message with the ERROR priority.
83 /// <param name="tag">The tag name of the log message.</param>
84 /// <param name="message">The log message to print.</param>
85 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
86 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
87 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
88 public static void Error(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
90 Print(Interop.Dlog.LogPriority.DLOG_ERROR, tag, message, file, func, line);
94 /// Prints a log message with the FATAL priority.
96 /// <param name="tag">The tag name of the log message.</param>
97 /// <param name="message">The log message to print.</param>
98 /// <param name="file">The source file path of the caller function. This argument will be set automatically by the compiler.</param>
99 /// <param name="func">The function name of caller function. This argument will be set automatically by the compiler.</param>
100 /// <param name="line">The line number of calling position. This argument will be set automatically by the compiler.</param>
101 public static void Fatal(string tag, string message, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0)
103 Print(Interop.Dlog.LogPriority.DLOG_FATAL, tag, message, file, func, line);
106 private static void Print(Interop.Dlog.LogPriority priority, string tag, string message, string file, string func, int line)
108 if (String.IsNullOrEmpty(file))
110 Interop.Dlog.Print(priority, tag, "%s", message);
114 Uri f = new Uri("file://" + file);
115 Interop.Dlog.Print(priority, tag, "%s: %s(%d) > %s", Path.GetFileName(f.AbsolutePath), func, line, message);