summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen/Log/ConsoleLogger.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Log/ConsoleLogger.cs')
-rw-r--r--Xamarin.Forms.Platform.Tizen/Log/ConsoleLogger.cs68
1 files changed, 68 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Log/ConsoleLogger.cs b/Xamarin.Forms.Platform.Tizen/Log/ConsoleLogger.cs
new file mode 100644
index 00000000..19e46e9e
--- /dev/null
+++ b/Xamarin.Forms.Platform.Tizen/Log/ConsoleLogger.cs
@@ -0,0 +1,68 @@
+using System;
+using System.IO;
+
+namespace Xamarin.Forms.Platform.Tizen
+{
+ /// <summary>
+ /// Logs a message to the console.
+ /// </summary>
+ internal class ConsoleLogger : ILogger
+ {
+ public void Debug(string tag, string message, string file, string func, int line)
+ {
+ Print("D", tag, message, file, func, line);
+ }
+
+ public void Verbose(string tag, string message, string file, string func, int line)
+ {
+ Print("V", tag, message, file, func, line);
+ }
+
+ public void Info(string tag, string message, string file, string func, int line)
+ {
+ Print("I", tag, message, file, func, line);
+ }
+
+ public void Warn(string tag, string message, string file, string func, int line)
+ {
+ Print("W", tag, message, file, func, line);
+ }
+
+ public void Error(string tag, string message, string file, string func, int line)
+ {
+ Print("E", tag, message, file, func, line);
+ }
+
+ public void Fatal(string tag, string message, string file, string func, int line)
+ {
+ Print("F", tag, message, file, func, line);
+ }
+
+ /// <summary>
+ /// Formats and prints the log information.
+ /// </summary>
+ /// <param name="level">Log level</param>
+ /// <param name="tag">Log tag</param>
+ /// <param name="message">Log message</param>
+ /// <param name="file">Full path to the file</param>
+ /// <param name="func">Function name</param>
+ /// <param name="line">Line number</param>
+ void Print(string level, string tag, string message, string file, string func, int line)
+ {
+ Uri f = new Uri(file);
+ Console.WriteLine(
+ String.Format(
+ "\n[{6:yyyy-MM-dd HH:mm:ss.ffff} {0}/{1}]\n{2}: {3}({4}) > {5}",
+ level, // 0
+ tag, // 1
+ Path.GetFileName(f.AbsolutePath), // 2
+ func, // 3
+ line, // 4
+ message, // 5
+ DateTime.Now // 6
+ )
+ );
+ }
+ }
+}
+