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.InteropServices;
20 using System.Runtime.CompilerServices;
22 namespace Tizen.Runtime
25 internal static class Log
27 static void Print(string tag, string message)
29 string[] lines = message.Split('\r');
30 foreach (string line in lines)
32 Console.WriteLine($"{tag} : {message}");
36 public static void Debug(string tag, string message)
38 Print($"D/{tag}", message);
41 public static void Info(string tag, string message)
43 Print($"I/{tag}", message);
46 public static void Error(string tag, string message)
48 Print($"E/{tag}", message);
52 internal static class ALog
54 const string Library = "libdlog.so.0";
55 const string TAG = "DOTNET_LAUNCHER";
57 public static void Debug(string message,
58 [CallerFilePath] string file = "",
59 [CallerMemberName] string func = "",
60 [CallerLineNumber] int line = 0)
62 Print(LogPriority.DLOG_DEBUG, TAG, message, file, func, line);
65 public static void Info(string message,
66 [CallerFilePath] string file = "",
67 [CallerMemberName] string func = "",
68 [CallerLineNumber] int line = 0)
70 Print(LogPriority.DLOG_DEBUG, TAG, message, file, func, line);
73 public static void Error(string message,
74 [CallerFilePath] string file = "",
75 [CallerMemberName] string func = "",
76 [CallerLineNumber] int line = 0)
78 Print(LogPriority.DLOG_DEBUG, TAG, message, file, func, line);
81 internal enum LogPriority
95 private static void Print(LogPriority priority, string tag, string message, string file, string func, int line)
97 FileInfo finfo = new FileInfo(file);
98 Print(priority, tag, "%s: %s(%d) > %s", finfo.Name, func, line, message);
101 [DllImportAttribute(Library, EntryPoint = "dlog_print")]
102 internal static extern int Print(LogPriority prio, string tag, string fmt, string file, string func, int line, string msg);