csharp: Document Eina.Log

Summary: ref T8293

Reviewers: brunobelo, segfaultxavi, felipealmeida

Reviewed By: felipealmeida

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Maniphest Tasks: T8293

Differential Revision: https://phab.enlightenment.org/D10255
This commit is contained in:
Lauro Moura 2019-09-30 23:05:36 -03:00 committed by Felipe Magno de Almeida
parent 774bc73320
commit 16e21c3314
1 changed files with 51 additions and 0 deletions

View File

@ -9,6 +9,7 @@ namespace Eina
{
// Manual wrappers around eina functions
/// <summary>EFL Logging facilities. (Since EFL 1.23)</summary>
public class Log
{
[DllImport(efl.Libs.Eina)] private static extern void eina_log_print(
@ -27,34 +28,55 @@ public class Log
[DllImport(efl.Libs.Eina)] private static extern Level eina_log_level_get();
/// <summary>The levels of logging.</summary>
public enum Level
{
/// <summary>Critical events.</summary>
Critical,
/// <summary>Error events.</summary>
Error,
/// <summary>Warning events.</summary>
Warning,
/// <summary>Informative events.</summary>
Info,
/// <summary>Debugging messages.</summary>
Debug,
/// <summary>Unknown events.</summary>
Unkown = (-2147483647 - 1)
}
/// <summary>The colors to be used by the logging system.</summary>
public class Color
{
/// <summary>Light red</summary>
public static string LIGHTRED = "\033[31;1m";
/// <summary>Red</summary>
public static string RED = "\033[31m";
/// <summary>Light blue</summary>
public static string LIGHTBLUE = "\033[34;1m";
/// <summary>Blue</summary>
public static string BLUE = "\033[34m";
/// <summary>Green</summary>
public static string GREEN = "\033[32;1m";
/// <summary>Yellow</summary>
public static string YELLOW = "\033[33;1m";
/// <summary>Orange</summary>
public static string ORANGE = "\033[0;33m";
/// <summary>White</summary>
public static string WHITE = "\033[37;1m";
/// <summary>Light cyan</summary>
public static string LIGHTCYAN = "\033[36;1m";
/// <summary>Cyan</summary>
public static string CYAN = "\033[36m";
/// <summary>Reset</summary>
public static string RESET = "\033[0m";
/// <summary>Bold</summary>
public static string HIGH = "\033[1m";
}
private static int domain = -1;
/// <summary>Static class initializer.</summary>
static Log()
{
const String name = "mono";
@ -80,41 +102,70 @@ public class Log
}
}
/// <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>
public static void Critical(String message, [CallerLineNumber] int line = 0, [CallerFilePath] string file = null, [CallerMemberName] string member = null)
{
EnsureDomainRegistered();
eina_log_print(domain, Level.Critical, file, member, line, message);
}
/// <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>
public static void Error(String message, [CallerLineNumber] int line = 0, [CallerFilePath] string file = null, [CallerMemberName] string member = null)
{
EnsureDomainRegistered();
eina_log_print(domain, Level.Error, file, member, line, message);
}
/// <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>
public static void Warning(String message, [CallerLineNumber] int line = 0, [CallerFilePath] string file = null, [CallerMemberName] string member = null)
{
EnsureDomainRegistered();
eina_log_print(domain, Level.Warning, file, member, line, message);
}
/// <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>
public static void Info(String message, [CallerLineNumber] int line = 0, [CallerFilePath] string file = null, [CallerMemberName] string member = null)
{
EnsureDomainRegistered();
eina_log_print(domain, Level.Info, file, member, line, message);
}
/// <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>
public static void Debug(String message, [CallerLineNumber] int line = 0, [CallerFilePath] string file = null, [CallerMemberName] string member = null)
{
EnsureDomainRegistered();
eina_log_print(domain, Level.Debug, file, member, line, message);
}
/// <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>
public static void GlobalLevelSet(Level level)
{
eina_log_level_set(level);
}
/// <summary>Gets the lowest level of messages that are not ignored.</summary>
/// <returns>The current message level.</returns>
public static Level GlobalLevelGet()
{
return eina_log_level_get();