public void Log(WurmApi.LogLevel level, string message, object source, Exception exception) { var nlogLevel = Convert(level); if (logger.IsEnabled(nlogLevel)) { string prefix = string.Empty; if (source != null) { var stringSource = source as string; if (!string.IsNullOrEmpty(stringSource)) { prefix += "." + stringSource; } else { prefix += source.GetType().Name; } } message = "WurmApi > " + prefix + ": " + message; logger.Log(nlogLevel, exception, message); logMessageProcessor.Handle(nlogLevel, message, exception); } }
LogLevel Convert(WurmApi.LogLevel wurmApiLevel) { switch (wurmApiLevel) { case WurmApi.LogLevel.Diag: return LogLevel.Trace; case WurmApi.LogLevel.Error: return LogLevel.Error; case WurmApi.LogLevel.Fatal: return LogLevel.Fatal; case WurmApi.LogLevel.Info: return LogLevel.Info; case WurmApi.LogLevel.Warn: return LogLevel.Warn; default: return LogLevel.Info; } }