Modify tizen coding style
[platform/core/dotnet/launcher.git] / Tizen.Runtime / Log.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.IO;
19 using System.Runtime.InteropServices;
20 using System.Runtime.CompilerServices;
21
22 namespace Tizen.Runtime
23 {
24     internal static class ALog
25     {
26         const string Library = "libdlog.so.0";
27         const string Tag = "DOTNET_LAUNCHER";
28
29         internal enum LogPriority
30         {
31             DLOG_UNKNOWN = 0,
32             DLOG_DEFAULT,
33             DLOG_VERBOSE,
34             DLOG_DEBUG,
35             DLOG_INFO,
36             DLOG_WARN,
37             DLOG_ERROR,
38             DLOG_FATAL,
39             DLOG_SILENT,
40             DLOG_PRIO_MAX,
41         }
42
43         public static void Debug(string message,
44                 [CallerFilePath] string file = "",
45                 [CallerMemberName] string function = "",
46                 [CallerLineNumber] int line = 0)
47         {
48             Print(LogPriority.DLOG_DEBUG, Tag, message, file, function, line);
49         }
50
51         public static void Info(string message,
52                 [CallerFilePath] string file = "",
53                 [CallerMemberName] string function = "",
54                 [CallerLineNumber] int line = 0)
55         {
56             Print(LogPriority.DLOG_INFO, Tag, message, file, function, line);
57         }
58
59         public static void Error(string message,
60                 [CallerFilePath] string file = "",
61                 [CallerMemberName] string function = "",
62                 [CallerLineNumber] int line = 0)
63         {
64             Print(LogPriority.DLOG_ERROR, Tag, message, file, function, line);
65         }
66
67         [DllImportAttribute(Library, EntryPoint = "dlog_print")]
68         internal static extern int Print(LogPriority priority, string tag, string format, string file, string function, int line, string msg);
69
70         private static void Print(LogPriority priority, string tag, string message, string file, string function, int line)
71         {
72             FileInfo fileInfo = new FileInfo(file);
73             Print(priority, tag, "%s: %s(%d) > %s", fileInfo.Name, function, line, message);
74         }
75
76     }
77 }