2017-12-06 16:03:55 -08:00
|
|
|
#pragma warning disable 1591
|
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
using System;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
using System.Diagnostics.Contracts;
|
|
|
|
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
namespace Eina
|
|
|
|
{
|
|
|
|
// Manual wrappers around eina functions
|
2017-11-23 16:49:22 -08:00
|
|
|
|
2019-10-03 23:46:29 -07:00
|
|
|
/// <summary>EFL Logging facilities.
|
|
|
|
///
|
|
|
|
/// Since EFL 1.23.
|
|
|
|
/// </summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public class Log
|
|
|
|
{
|
|
|
|
[DllImport(efl.Libs.Eina)] private static extern void eina_log_print(
|
|
|
|
int domain,
|
|
|
|
Level level,
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)] String file,
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)] String function,
|
|
|
|
int line,
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)] String message);
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] private static extern int eina_log_domain_register(
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)] String name,
|
|
|
|
[MarshalAs(UnmanagedType.LPStr)] String color);
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] private static extern void eina_log_level_set(Level level);
|
|
|
|
|
|
|
|
[DllImport(efl.Libs.Eina)] private static extern Level eina_log_level_get();
|
|
|
|
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>The levels of logging.</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public enum Level
|
|
|
|
{
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Critical events.</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
Critical,
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Error events.</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
Error,
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Warning events.</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
Warning,
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Informative events.</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
Info,
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Debugging messages.</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
Debug,
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Unknown events.</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
Unkown = (-2147483647 - 1)
|
|
|
|
}
|
|
|
|
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>The colors to be used by the logging system.</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public class Color
|
|
|
|
{
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Light red</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string LIGHTRED = "\033[31;1m";
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Red</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string RED = "\033[31m";
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Light blue</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string LIGHTBLUE = "\033[34;1m";
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Blue</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string BLUE = "\033[34m";
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Green</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string GREEN = "\033[32;1m";
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Yellow</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string YELLOW = "\033[33;1m";
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Orange</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string ORANGE = "\033[0;33m";
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>White</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string WHITE = "\033[37;1m";
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Light cyan</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string LIGHTCYAN = "\033[36;1m";
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Cyan</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string CYAN = "\033[36m";
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Reset</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string RESET = "\033[0m";
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Bold</summary>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static string HIGH = "\033[1m";
|
|
|
|
}
|
|
|
|
|
|
|
|
private static int domain = -1;
|
|
|
|
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Static class initializer.</summary>
|
2019-01-16 04:47:09 -08:00
|
|
|
static Log()
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
const String name = "mono";
|
|
|
|
const String color = "\033[32;1m";
|
2019-01-16 04:47:09 -08:00
|
|
|
|
|
|
|
// Maybe move this check outside when other eina stuff get support?
|
|
|
|
domain = eina_log_domain_register(name, color);
|
|
|
|
if (domain < 0)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
|
|
|
Console.WriteLine("Error: Couldn't register Eina log domain for name {0}.", name);
|
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
else
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
|
|
|
Info($"Registered mono domain with number {domain}");
|
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void EnsureDomainRegistered()
|
|
|
|
{
|
|
|
|
if (domain < 0)
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
{
|
|
|
|
throw new InvalidOperationException("Log domain is not registered.");
|
|
|
|
}
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|
|
|
|
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Prints a critical message with context info. This context is filled automatically by the C# compiler.</summary>
|
|
|
|
/// <param name="message">The message to be printed.</param>
|
|
|
|
/// <param name="line">The line number this method was called from.</param>
|
|
|
|
/// <param name="file">The file this method was called from.</param>
|
|
|
|
/// <param name="member">The enlosing method this method was called from.</param>
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
public static void Critical(String message, [CallerLineNumber] int line = 0, [CallerFilePath] string file = null, [CallerMemberName] string member = null)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
EnsureDomainRegistered();
|
|
|
|
eina_log_print(domain, Level.Critical, file, member, line, message);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Prints an error message with context info. This context is filled automatically by the C# compiler.</summary>
|
|
|
|
/// <param name="message">The message to be printed.</param>
|
|
|
|
/// <param name="line">The line number this method was called from.</param>
|
|
|
|
/// <param name="file">The file this method was called from.</param>
|
|
|
|
/// <param name="member">The enlosing method this method was called from.</param>
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
public static void Error(String message, [CallerLineNumber] int line = 0, [CallerFilePath] string file = null, [CallerMemberName] string member = null)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
EnsureDomainRegistered();
|
|
|
|
eina_log_print(domain, Level.Error, file, member, line, message);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Prints a warning message with context info. This context is filled automatically by the C# compiler.</summary>
|
|
|
|
/// <param name="message">The message to be printed.</param>
|
|
|
|
/// <param name="line">The line number this method was called from.</param>
|
|
|
|
/// <param name="file">The file this method was called from.</param>
|
|
|
|
/// <param name="member">The enlosing method this method was called from.</param>
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
public static void Warning(String message, [CallerLineNumber] int line = 0, [CallerFilePath] string file = null, [CallerMemberName] string member = null)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
EnsureDomainRegistered();
|
|
|
|
eina_log_print(domain, Level.Warning, file, member, line, message);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Prints an informative message with context info. This context is filled automatically by the C# compiler.</summary>
|
|
|
|
/// <param name="message">The message to be printed.</param>
|
|
|
|
/// <param name="line">The line number this method was called from.</param>
|
|
|
|
/// <param name="file">The file this method was called from.</param>
|
|
|
|
/// <param name="member">The enlosing method this method was called from.</param>
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
public static void Info(String message, [CallerLineNumber] int line = 0, [CallerFilePath] string file = null, [CallerMemberName] string member = null)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
EnsureDomainRegistered();
|
|
|
|
eina_log_print(domain, Level.Info, file, member, line, message);
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Prints a debug message with context info. This context is filled automatically by the C# compiler.</summary>
|
|
|
|
/// <param name="message">The message to be printed.</param>
|
|
|
|
/// <param name="line">The line number this method was called from.</param>
|
|
|
|
/// <param name="file">The file this method was called from.</param>
|
|
|
|
/// <param name="member">The enlosing method this method was called from.</param>
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
public static void Debug(String message, [CallerLineNumber] int line = 0, [CallerFilePath] string file = null, [CallerMemberName] string member = null)
|
2017-11-23 16:49:22 -08:00
|
|
|
{
|
|
|
|
EnsureDomainRegistered();
|
|
|
|
eina_log_print(domain, Level.Debug, file, member, line, message);
|
|
|
|
}
|
|
|
|
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Sets the highest level log messages should be printed. Values larger than this one are ignored.</summary>
|
|
|
|
/// <param name="level">The global message level.</param>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static void GlobalLevelSet(Level level)
|
|
|
|
{
|
|
|
|
eina_log_level_set(level);
|
|
|
|
}
|
|
|
|
|
2019-09-30 19:05:36 -07:00
|
|
|
/// <summary>Gets the lowest level of messages that are not ignored.</summary>
|
|
|
|
/// <returns>The current message level.</returns>
|
2017-11-23 16:49:22 -08:00
|
|
|
public static Level GlobalLevelGet()
|
|
|
|
{
|
|
|
|
return eina_log_level_get();
|
|
|
|
}
|
|
|
|
}
|
mono: fix space and brace warnings of StyleCop
Summary:
The following warning rules of StyleCop are checked.
Space rules : SA1000, SA1003, SA1008, SA1009, SA1010, SA1011
Brace rules : SA1500, SA1501, SA1502, SA1503, SA1513
Indentation is also applied.
Reviewers: lauromoura, felipealmeida, vitor.sousa, woohyun
Reviewed By: vitor.sousa
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D8485
2019-04-02 07:51:05 -07:00
|
|
|
|
2017-11-23 16:49:22 -08:00
|
|
|
}
|