using UnityEngine; using System.Collections; using System.IO; using System; namespace LunarCatsStudio.SuperCombiner { public class Logger { string _logs = " "; static Logger _instance; static bool _display = true; /// /// logs level /// public enum LogLevel { LOG_DEBUG, LOG_WARNING, LOG_ERROR } /// /// get instance of the logger singleton /// public static Logger Instance { get { if (_instance == null) { _instance = new Logger(); } return _instance; } } /// /// General switch for display or not new logs add in logger store /// public static bool Display { get { return _display; } set { _display = value; } } /// /// add new log in the logger store /// /// log tag /// log message /// log level /// display or not this new log in editor console public void AddLog(string tag, string log, LogLevel level = LogLevel.LOG_DEBUG, bool display = true) { string log_type = " "; string new_log = "[" + tag + "] " + log; switch (level) { case LogLevel.LOG_WARNING: log_type = "WARNING: "; if (display && _display) Debug.LogWarning(new_log); break; case LogLevel.LOG_ERROR: log_type = "ERROR: "; if (display && _display) Debug.LogError(new_log); break; default: log_type = "DEBUG: "; if (display && _display) Debug.Log(new_log); break; } _logs = _logs + log_type + new_log + "\n"; } /// /// clear logs store /// public void ClearLogs() { _logs = " "; } /// /// get logs store content /// /// public string GetLogs() { return _logs; } } }