From 5c75df48fe2a4e2ba925b81987359cf043ff0f20 Mon Sep 17 00:00:00 2001 From: Jeremy Smitherman Date: Tue, 9 May 2023 16:13:52 -0500 Subject: [PATCH] Initial commit --- Logging.cs | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Logging.cs diff --git a/Logging.cs b/Logging.cs new file mode 100644 index 0000000..a378482 --- /dev/null +++ b/Logging.cs @@ -0,0 +1,50 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace ZelleGames.Log +{ + public enum LogLevel { DEBUG, INFO, WARN, ERROR } + + public static class Logging + { + //static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger(); + public static void Init() + { + //var config = new NLog.Config.LoggingConfiguration(); + //var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "log.txt" }; + //var loglevel = (Application.isEditor) ? NLog.LogLevel.Debug : NLog.LogLevel.Info; + //config.AddRule(loglevel, NLog.LogLevel.Fatal, logfile); + + //NLog.LogManager.Configuration = config; + } + + public static void Log(LogLevel level, string message, System.Exception ex) + { + switch (level) + { + case LogLevel.DEBUG: + //Logger.Debug(message); + Debug.Log(message); + break; + case LogLevel.INFO: + //Logger.Info(message); + Debug.Log(message); + break; + case LogLevel.WARN: + Debug.LogWarning(message); + //Logger.Warn(message); + break; + case LogLevel.ERROR: + Debug.LogError(message); + //Logger.Error(ex, message); + break; + } + } + + public static void Log(LogLevel level, string message) + { + Log(level, message, null); + } + } +} \ No newline at end of file