Skip to main content
Version: 0.1.0

Class Logging

Namespace: WukongMp.Api
Assembly: WukongMp.Api.dll

Provides static logging methods that can be used throughout the codebase without needing to inject a logger instance.

public static class Logging

Inheritance​

object ← Logging

Inherited Members​

object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Methods​

LogCritical(string?, params object?[])​

Logs a critical error message. This method is active in all build configurations and is suitable for logging critical errors or exceptions that occur during the mod's operation, indicating a severe failure that may result in shutdown or data loss.

public static void LogCritical(string? message, params object?[] args)

Parameters​

message string?

The message template to log. Use structured logging syntax (e.g., "User {UserId} logged in").

args object?[]

The arguments to be formatted into the message template.

LogCritical(Exception?, string?, params object?[])​

Logs a critical error message along with an exception. This method is active in all build configurations and is suitable for logging critical errors or exceptions that occur during the mod's operation, providing additional context from the exception and indicating a severe failure that may result in shutdown or data loss.

public static void LogCritical(Exception? ex, string? message = null, params object?[] args)

Parameters​

ex Exception?

The exception to log. This can be null if no exception is being logged, but the method will still log the message and arguments.

message string?

The message template to log. Use structured logging syntax (e.g., "User {UserId} logged in"). This parameter is optional and can be null, in which case only the exception will be logged, but the log entry will still be marked as critical.

args object?[]

The arguments to be formatted into the message template. This parameter is optional and can be empty if no additional context is needed.

LogDebug(string?, params object?[])​

Logs a debug message. This method is only active in DEBUG builds and will be stripped out in release builds to avoid performance overhead.

public static void LogDebug(string? message, params object?[] args)

Parameters​

message string?

The message template to log. Use structured logging syntax (e.g., "User {UserId} logged in").

args object?[]

The arguments to be formatted into the message template.

LogError(string?, params object?[])​

Logs an error message. This method is active in all build configurations and is suitable for logging errors or exceptions that occur during the mod's operation.

public static void LogError(string? message, params object?[] args)

Parameters​

message string?

The message template to log. Use structured logging syntax (e.g., "User {UserId} logged in").

args object?[]

The arguments to be formatted into the message template.

LogError(Exception?, string?, params object?[])​

Logs an error message along with an exception. This method is active in all build configurations and is suitable for logging errors or exceptions that occur during the mod's operation, providing additional context from the exception.

public static void LogError(Exception? ex, string? message = null, params object?[] args)

Parameters​

ex Exception?

The exception to log. This can be null if no exception is being logged, but the method will still log the message and arguments.

message string?

The message template to log. Use structured logging syntax (e.g., "User {UserId} logged in"). This parameter is optional and can be null, in which case only the exception will be logged.

args object?[]

The arguments to be formatted into the message template. This parameter is optional and can be empty if no additional context is needed.

LogException(Exception, string?, params object?[])​

Logs an exception with an optional message and arguments. This method is a convenience wrapper around LogError that allows you to log an exception along with a custom message and structured arguments. If the message is null, it will default to "An exception occurred". This method is active in all build configurations and is suitable for logging exceptions that occur during the mod's operation, providing additional context from the exception and any relevant information through the message and arguments.

public static void LogException(Exception ex, string? message = null, params object?[] args)

Parameters​

ex Exception

The exception to log.

message string?

An optional message template to log alongside the exception. Use structured logging syntax (e.g., "User {UserId} logged in"). If null, a default message will be used.

args object?[]

The arguments to be formatted into the message template. This parameter is optional and can be empty if no additional context is needed.

LogInformation(string?, params object?[])​

Logs an informational message. This method is active in all build configurations and is suitable for logging general information about the mod's operation.

public static void LogInformation(string? message, params object?[] args)

Parameters​

message string?

The message template to log. Use structured logging syntax (e.g., "User {UserId} logged in").

args object?[]

The arguments to be formatted into the message template.

LogTrace(string?, params object?[])​

Logs a trace message. This method is only active in DEBUG builds and will be stripped out in release builds to avoid performance overhead.

public static void LogTrace(string? message, params object?[] args)

Parameters​

message string?

The message template to log. Use structured logging syntax (e.g., "User {UserId} logged in").

args object?[]

The arguments to be formatted into the message template.

LogWarning(string?, params object?[])​

Logs a warning message. This method is active in all build configurations and is suitable for logging potential issues or important events that are not necessarily errors.

public static void LogWarning(string? message, params object?[] args)

Parameters​

message string?

The message template to log. Use structured logging syntax (e.g., "User {UserId} logged in").

args object?[]

The arguments to be formatted into the message template.

  • Methods
    • LogCritical(string?, params object?[])
    • LogCritical(Exception?, string?, params object?[])
    • LogDebug(string?, params object?[])
    • LogError(string?, params object?[])
    • LogError(Exception?, string?, params object?[])
    • LogException(Exception, string?, params object?[])
    • LogInformation(string?, params object?[])
    • LogTrace(string?, params object?[])
    • LogWarning(string?, params object?[])