Skip to content

Logging Class

Definition

namespace Sharplog

public static class Logging
Object
Logging

Class responsible for logging.

Methods

Name Modifiers Returns
Initialize() public static
Dispose() public static
Log(LogLevel, object, string, Exception, bool) public static
LogDebug(object, string, Exception, bool) public static
LogTrace(object, string, Exception, bool) public static
LogInfo(object, string, Exception, bool) public static
LogWarning(object, string, Exception, bool) public static
LogError(object, string, Exception, bool) public static
LogFatal(object, string, Exception, bool) public static

Methods

Initialize()

public static void Initialize()

Initializes the logger. The logger will automatically initialize itself with the first log function call. Use this function if you want to initialize before you start logging.

Dispose()

public static void Dispose()

Releases resources and logs all remaining logs. Should be called before exiting the program.

Log(LogLevel, object, string, Exception, bool)

public static void Log(
    LogLevel level,
    object message,
    string? tag = null,
    Exception? exception = null,
    bool stackTrace = false)

Logs a log message.

Parameter

level LogLevel ·
The level of the log.
message object ·
The message of the log. Gets converted to a string using .toString().
tag string · null
The tag of the log.
exception Exception · null
The exception of the log.
stackTrace bool · false
Wether the log should include the stack trace.

LogDebug(object, string, Exception, bool)

public static void LogDebug(
    object message,
    string tag = null, 
    Exception exception = null, 
    bool stackTrace = false)

Logs a debug log message.

Parameter

message object ·
The message of the log. Gets converted to a string using .toString().
tag string · null
The tag of the log.
exception Exception · null
The exception of the log.
stackTrace bool · false
Wether the log should include the stack trace.

LogTrace(object, string, Exception, bool)

public static void LogTrace(
    object message,
    string tag = null, 
    Exception exception = null, 
    bool stackTrace = false)

Logs a trace log message.

Parameter

message object ·
The message of the log. Gets converted to a string using .toString().
tag string · null
The tag of the log.
exception Exception · null
The exception of the log.
stackTrace bool · false
Wether the log should include the stack trace.

LogInfo(object, string, Exception, bool)

public static void LogInfo(
    object message,
    string tag = null, 
    Exception exception = null, 
    bool stackTrace = false)

Logs an information log message.

Parameter

message object ·
The message of the log. Gets converted to a string using .toString().
tag string · null
The tag of the log.
exception Exception · null
The exception of the log.
stackTrace bool · false
Wether the log should include the stack trace.

LogWarning(object, string, Exception, bool)

public static void LogWarning(
    object message,
    string tag = null, 
    Exception exception = null, 
    bool stackTrace = false)

Logs a warning log message.

Parameter

message object ·
The message of the log. Gets converted to a string using .toString().
tag string · null
The tag of the log.
exception Exception · null
The exception of the log.
stackTrace bool · false
Wether the log should include the stack trace.

LogError(object, string, Exception, bool)

public static void LogError(
    object message,
    string tag = null, 
    Exception exception = null, 
    bool stackTrace = false)

Logs an error log message.

Parameter

message object ·
The message of the log. Gets converted to a string using .toString().
tag string · null
The tag of the log.
exception Exception · null
The exception of the log.
stackTrace bool · false
Wether the log should include the stack trace.

LogFatal(object, string, Exception, bool)

public static void LogFatal(
    object message,
    string tag = null, 
    Exception exception = null, 
    bool stackTrace = false)

Logs a fatal log message and exits the program with code 1.

Parameter

message object ·
The message of the log. Gets converted to a string using .toString().
tag string · null
The tag of the log.
exception Exception · null
The exception of the log.
stackTrace bool · false
Wether the log should include the stack trace.