public UModLogger(RustApiOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _logLevel = options.LogLevel; _logToFile = options.LogToFile; }
public RustApiOptions( string endpoint, bool logToFile = false, MinimumLogLevel logLevel = MinimumLogLevel.Information ) { if (!Enum.IsDefined(typeof(MinimumLogLevel), logLevel)) { throw new InvalidEnumArgumentException(nameof(logLevel), (int)logLevel, typeof(MinimumLogLevel)); } Endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint)); LogToFile = logToFile; LogLevel = logLevel; }
public void SetMinimuLogLevelFromString(string minimumLevel) { // Be forgiving... :P if (String.IsNullOrEmpty(minimumLevel)) { return; } MinimumLogLevel level; if (!Enum.TryParse(minimumLevel, true, out level)) { Log.Warn(Tag, $"Unknown log level name: {minimumLevel}"); return; } Log.Info(Tag, $"Setting log level to {level}"); MinimumLogLevel = level; }