Exemplo n.º 1
0
 private static void UnityLogFormat(LogType type, LogOption option, Object context, string tag, string format, params object[] args)
 {
     try
     {
         if (args.Length > 0)
         {
             Debug.LogFormat(type, option, context, string.Concat(tag, ":", format), args);
         }
         else
         {
             if (type == LogType.Log)
             {
                 Debug.Log(string.Concat(tag, ":", format), context);
             }
             else if (type == LogType.Warning)
             {
                 Debug.LogWarning(string.Concat(tag, ":", format), context);
             }
             else if (type == LogType.Error)
             {
                 Debug.LogError(string.Concat(tag, ":", format), context);
             }
         }
     }
     catch (Exception ex)
     {
         DebugUtility.LogError(LoggerTags.Engine, "The formatting-string or argument is abnormal.");
         DebugUtility.LogException(ex);
     }
 }
Exemplo n.º 2
0
        public static void DelLogByDay(int daysBefore, LogOption option)
        {
            if (daysBefore <= 0)
            {
                return;
            }
            string from = DateTime.Now.AddDays(-daysBefore).ToString("yyyyMMdd");
            string to   = DateTime.Now.ToString("yyyyMMdd");
            string dir  = Application.StartupPath + "\\Log\\";
            string dic  = null;

            foreach (string d in Directory.GetDirectories(dir))
            {
                dic = Path.GetFileName(d);
                if (int.Parse(dic) >= int.Parse(from) && int.Parse(dic) < int.Parse(to))
                {
                    if (option == LogOption.All)
                    {
                        Directory.Delete(d, true);
                    }
                    else if (option == LogOption.Application)
                    {
                        File.Delete(Path.Combine(d, "App.log"));
                    }
                    else
                    {
                        File.Delete(Path.Combine(d, "Package.log"));
                    }
                }
            }
        }
Exemplo n.º 3
0
        static int LogTypeOptionsToLogMessageFlags(LogType logType, LogOption logOptions)
        {
            LogMessageFlags logMessageFlags;

            if (logType == LogType.Log) // LogType::Log
            {
                logMessageFlags = LogMessageFlags.ScriptingLog;
            }
            else if (logType == LogType.Warning) // LogType::Warning
            {
                logMessageFlags = LogMessageFlags.ScriptingWarning;
            }
            else if (logType == LogType.Error) // LogType::Error
            {
                logMessageFlags = LogMessageFlags.ScriptingError;
            }
            else if (logType == LogType.Exception) // LogType::Exception
            {
                logMessageFlags = LogMessageFlags.ScriptingException;
            }
            else
            {
                logMessageFlags = LogMessageFlags.ScriptingAssertion;
            }

            if (logOptions == LogOption.NoStacktrace)
            {
                logMessageFlags |= LogMessageFlags.DontExtractStacktrace;
            }

            return((int)logMessageFlags);
        }
Exemplo n.º 4
0
        public static void Unity(string msg, bool stackTrace = true, Level level = Level.INFO)
        {
            if ((int)level < MIN_LEVEL)
            {
                return;
            }
#if UNITY_EDITOR
#else
            if ((int)level < BUILD_MIN)
            {
                return;
            }
#endif
            msg = $"Frame {ETime.FrameNumber}: {msg}";
            LogOption lo      = stackTrace ? LogOption.None : LogOption.NoStacktrace;
            LogType   unityLT = LogType.Log;
            file.WriteLine(msg);
            if (level == Level.WARNING)
            {
                unityLT = LogType.Warning;
            }
            if (level == Level.ERROR)
            {
                unityLT = LogType.Error;
                Debug.LogError(msg);
            }
            else
            {
                Debug.LogFormat(unityLT, lo, null, msg.Replace("{", "{{").Replace("}", "}}"));
            }
        }
Exemplo n.º 5
0
 public static void LogFormat(LogType logType, LogOption logOptions, Object context, string format, params object[] args)
 {
     if (isDebugBuild)
     {
         Debug.LogFormat(logType, logOptions, context, logTag + ": " + format, args);
     }
 }
Exemplo n.º 6
0
 public FilesMiddleware(RequestDelegate next, IOptionsMonitor <LogOption> optionsMonitor, IOptionsSnapshot <LogOption> optionsSnapshot, IOptionsSnapshot <UserSecretsOptions> userSecretsOptions)
 {
     Console.WriteLine($"{nameof(FilesMiddleware)} reached");
     Console.WriteLine($"User Secrets: Username {userSecretsOptions.Value.Username} - Password {userSecretsOptions.Value.Password}");
     _next    = next;
     _options = optionsSnapshot.Value;
     optionsMonitor.OnChange(ChangeListner); //this is invoked when we save appsettings.json
 }
Exemplo n.º 7
0
        public HomeController(IOptionsSnapshot <LogOption> optionsSnapshot, ILoggerFactory loggerFactory, INotifier notifier)
        {
            Console.WriteLine($"{nameof(HomeController)} reached");

            _option   = optionsSnapshot.Value;
            _log      = loggerFactory.CreateLogger(typeof(HomeController));
            _notifier = notifier;
        }
Exemplo n.º 8
0
 public static void LogFormat(LogType logType, LogOption logOptions, Object context, string format, params object[] args)
 {
     if (LogSwitch == false)
     {
         return;
     }
     UnityEngine.Debug.LogFormat(logType, logOptions, context, format, args);
 }
Exemplo n.º 9
0
        public void Log(string message, LogType logType, LogOption logOption, Object context = null)
        {
            var fullMessage = _richTextFactory
                              .UnstyledText(TitleBacked)
                              .UnstyledText(message).ToString();

            _richTextFactory.Clear();

            Debug.LogFormat(logType, logOption, context, fullMessage);
        }
Exemplo n.º 10
0
 protected override void OnClosing(CancelEventArgs e)
 {
     user.earned         += dayEarned;
     user.spent          += daySpent;
     user.IsLogged        = false;
     currentLog.SingedOut = DateTime.Now;
     currentLog.Earned    = dayEarned;
     currentLog.Spent     = daySpent;
     LogOption.AddLogEntity(ref currentLog);
     UserOption.updateUser(ref user);
     base.OnClosing(e);
 }
Exemplo n.º 11
0
        public static void LogSticky(string message, string file, LogType logType, LogOption logOptions, int instanceId)
        {
            int mode = LogTypeOptionsToLogMessageFlags(logType, logOptions) | (int)LogMessageFlags.StickyLog;

            LogEntries.AddMessageWithDoubleClickCallback(new LogEntry
            {
                message    = message,
                file       = file,
                mode       = mode,
                identifier = k_GTFLogIdentifier,
                instanceID = instanceId,
            });
        }
Exemplo n.º 12
0
        public static void LogFormat(LogType logType, LogOption logOptions, Object context, string format, params object[] args)
        {
            var l = unityLogger.logHandler as DebugLogHandler;

            if (l == null)
            {
                unityLogger.LogFormat(logType, context, format, args);
            }
            else
            {
                l.LogFormat(logType, logOptions, context, format, args);
            }
        }
Exemplo n.º 13
0
        public static void LogFormat(LogType logType, LogOption logOptions, Object context, string format, params object[] args)
        {
            DebugLogHandler debugLogHandler = Debug.unityLogger.logHandler as DebugLogHandler;
            bool            flag            = debugLogHandler == null;

            if (flag)
            {
                Debug.unityLogger.LogFormat(logType, context, format, args);
            }
            else
            {
                debugLogHandler.LogFormat(logType, logOptions, context, format, args);
            }
        }
Exemplo n.º 14
0
        public static void LogFormat(LogType logType, LogOption logOptions, UnityEngine.Object context, string format, DebugTag debugTag = null, params object[] args)
        {
            if (debugTag != null && !HasTag(debugTag))
            {
                return;
            }

            if (!Settings.LoggerData.LogType.HasFlag(logType))
            {
                return;
            }

            UnityEngine.LogType convertLogType = (UnityEngine.LogType)(int) Mathf.Log((int)logType, 2);

            UnityEngine.Debug.LogFormat(convertLogType, logOptions, context, format, args);
        }
Exemplo n.º 15
0
        public void SendtoLog(string str, LogOption option)
        {
            if (this.richTextBox1.InvokeRequired)
            {
                LogMessageDelegate d = new LogMessageDelegate(SendtoLog);
                this.Invoke(d);
            }
            else
            {
                richTextBox1.SelectionCharOffset = 2;
                richTextBox1.SelectedText        = string.Empty;
                richTextBox1.SelectionStart      = richTextBox1.TextLength;

                switch (option)
                {
                case LogOption.Normal:
                    richTextBox1.SelectionColor     = Color.White;
                    richTextBox1.SelectionAlignment = HorizontalAlignment.Left;
                    break;

                case LogOption.System:
                    richTextBox1.SelectionColor     = Color.Yellow;
                    richTextBox1.SelectionAlignment = HorizontalAlignment.Left;
                    break;

                case LogOption.Error:
                    richTextBox1.SelectionColor     = Color.FromArgb(0xd9, 0x2b, 0x2b);
                    richTextBox1.SelectionAlignment = HorizontalAlignment.Left;
                    break;

                case LogOption.Equation:
                    richTextBox1.SelectionColor     = Color.PeachPuff;
                    richTextBox1.SelectionAlignment = HorizontalAlignment.Left;
                    break;

                case LogOption.Result:
                    richTextBox1.SelectionColor     = Color.LightBlue;
                    richTextBox1.SelectionAlignment = HorizontalAlignment.Left;
                    break;
                }

                richTextBox1.AppendText(str);
                richTextBox1.ScrollToCaret();
            }
        }
Exemplo n.º 16
0
        public static void LogFormat(LogType logType
                                     , LogOption logOptions
                                     , Object context
                                     , string format
                                     , params object[] args)
        {
            bool mutingThisLog = !Instance.LogEnabled();

            if (logType != LogType.Log)
            {
                if (!Instance.AllowWarningAndErrorMuting)
                {
                    mutingThisLog = false;
                }
            }

            if (mutingThisLog)
            {
                return;
            }

            Debug.LogFormat(logType, logOptions, context, Instance.m_ColorString + format, args);
        }
Exemplo n.º 17
0
 private void ChangeListner(LogOption arg1, string arg2)
 {
     Console.WriteLine($"NotifyChange :{arg1.Default}:{arg2?.ToString()}");
 }
Exemplo n.º 18
0
 public static void LogSticky(LogType logType, LogOption logOptions, string message)
 {
     LogSticky(logType, logOptions, message, string.Empty, 0);
 }
Exemplo n.º 19
0
 public static void LogFormat(LogType logType, LogOption logOptions, Object context, string format, params object[] args)
 {
     Debug.LogFormat(logType, logOptions, context, format, args);
 }
Exemplo n.º 20
0
 public LogData(DateTime t, LogOption o, LogSource s, string d)
 {
     time = t;  option = o; source = s; data = d;
 }
Exemplo n.º 21
0
 [Conditional("DUMMY")] public static void LogFormat(LogType logType, LogOption logOptions, Object context, string format, params object[] args)
 {
 }
Exemplo n.º 22
0
 public LogContextProperty(LogOption logOption)
 {
     Log = logOption;
 }
Exemplo n.º 23
0
 public static void LogSticky(LogType logType, LogOption logOptions, string message, string file, int instanceId)
 {
     ConsoleWindowBridge.LogSticky(message, file, logType, logOptions, instanceId);
 }
Exemplo n.º 24
0
 public void LogFormat(LogType logType, LogOption logOptions, Object context, string format, params object[] args)
 {
     DebugLogHandler.Internal_Log(logType, logOptions, string.Format(format, args), context);
 }
Exemplo n.º 25
0
 public void Log(string message, LogOption logOption) => Log(message, LogType.Log, logOption);
Exemplo n.º 26
0
 internal static extern void Internal_Log(LogType level, LogOption options, string msg, Object obj);
Exemplo n.º 27
0
 [ThreadAndSerializationSafe]         // 0x00000001800D4E50-0x00000001800D4E60
 internal static void Internal_Log(LogType level, LogOption options, string msg, Object obj)
 {
 }                                    // 0x00000001809669B0-0x0000000180966A10
Exemplo n.º 28
0
 internal static extern void LogSticky(int identifier, LogType logType, LogOption logOptions, string message, Object context = null);
Exemplo n.º 29
0
 public LogbookAttribute(LogOption logOption) : base("LogbookAttribute")
 {
     m_LogOption = logOption;
 }
Exemplo n.º 30
0
 // allows messages of selected type to show in log file
 static public void SetOption(LogOption o)
 {
     option |= o;
 }