Class EmailLogger
- Namespace
- FishMMO.Logging
- Assembly
- FishMMO-Logger.dll
Implements ILogger to send critical/error log entries as emails to specified recipients. Email sending is asynchronous and non-blocking.
public class EmailLogger : ILogger, IDisposable
- Inheritance
-
EmailLogger
- Implements
- Inherited Members
Constructors
EmailLogger(EmailLoggerConfig, Action<string>)
Initializes a new instance of the EmailLogger.
public EmailLogger(EmailLoggerConfig config, Action<string> internalLogCallback = null)
Parameters
configEmailLoggerConfigConfiguration for the email logger, including SMTP settings and recipient addresses.
internalLogCallbackAction<string>Optional: A callback action for internal messages from the logger itself. If null, defaults to Console.WriteLine.
Properties
AllowedLevels
Gets the set of log levels that this logger is allowed to process. If a log entry's level is not in this set, it will be ignored by this logger.
public IReadOnlyCollection<LogLevel> AllowedLevels { get; }
Property Value
HandlesConsoleParts
Gets a value indicating whether this logger is specifically designed to handle console output from the Log.WritePartsToConsole method. If true, this logger will be excluded from general dispatch when WritePartsToConsole has already sent output to the primary console formatter.
public bool HandlesConsoleParts { get; }
Property Value
IsEnabled
Gets whether this logger is currently enabled.
public bool IsEnabled { get; }
Property Value
Methods
Dispose()
Disposes the EmailLogger. For EmailLogger, this typically means no unmanaged resources need explicit disposal.
public void Dispose()
Log(LogEntry)
Logs a structured entry by sending it as an email.
public Task Log(LogEntry entry)
Parameters
entryLogEntryThe log entry to send.
Returns
SetAllowedLevels(HashSet<LogLevel>)
Sets the specific log levels that this logger is allowed to process. Setting this will replace any previously configured allowed levels.
public void SetAllowedLevels(HashSet<LogLevel> levels)
Parameters
levelsHashSet<LogLevel>A HashSet containing the LogLevels to allow. If null or empty, no levels will be allowed.
SetEnabled(bool)
Sets the enabled state of the logger.
public void SetEnabled(bool enabled)
Parameters
enabledboolTrue to enable, false to disable.