Esempio n. 1
0
        void PostfixLogLevelInfo(ref string message, ref string cmessage, LoggerLogLevel level)
        {
            var logName = level.ToString().ToUpper();

            message  = "[" + logName + "] " + message;
            cmessage = ("[" + logName + "] " + Styles.LogLevel[level]) + cmessage;
        }
Esempio n. 2
0
 private void OnLogBroadcast(LoggerLogLevel level, string logtext)
 {
     if ((int)MinLogLevel <= (int)level)
     {
         WriteLog(level, logtext);
     }
 }
Esempio n. 3
0
 private void OnLogBroadcast(LoggerLogLevel level, string logtext)
 {
     if ((int)MinLogLevel <= (int)level)
     {
         WriteLog(level, logtext);
     }
 }
Esempio n. 4
0
 public override void WriteLog(LoggerLogLevel level, DateTime logDateTime, string logText)
 {
     lock (_lock)
     {
         var contents = $"{level}: {logDateTime:d} {logDateTime:T}: {logText} \n";
         File.AppendAllText(LogFileName, contents);
     }
 }
Esempio n. 5
0
 public override void WriteLog(LoggerLogLevel level, DateTime logDateTime, string logText)
 {
     lock (_lock)
     {
         var contents = $"{level}: {logDateTime:d} {logDateTime:T}: {logText} \n";
         File.AppendAllText(LogFileName, contents);
     }
 }
Esempio n. 6
0
        // Broadcast Log Messages
        private void BroadcasterOnLogBroadcast(LoggerLogLevel level, string logText)
        {
            var keys = ListAllKeys();


            foreach (var key in keys)
            {
                LoggerLogLevel minLevel;

                lock (ConnectedClientLogLevels)
                {
                    if (!ConnectedClientLogLevels.ContainsKey(key))
                    {
                        continue;
                    }
                    minLevel = ConnectedClientLogLevels[key];
                }



                // incoming log is the level was want
                if ((int)minLevel > (int)level)
                {
                    continue;
                }


                // ok send message through channel!
                var callback = GetCallback(key);

                if (!IsOpen(callback))
                {
                    DeleteKey(key);
                    continue;
                }


                try
                {
                    // callback...
                    callback.ReceiveLogMessage(new LogMessageDto
                    {
                        ComputerName    = Environment.MachineName,
                        LogDateTime     = DateTime.Now,
                        LogLevel        = level.ToString(),
                        LogText         = logText,
                        ApplicationName = Assembly.GetEntryAssembly().FullName
                    });
                }
                catch (Exception)
                {
                    DeleteKey(key);
                }
            }
        }
Esempio n. 7
0
        void LogRotate(LoggerLogLevel type)
        {
            string fileName = LogFilePaths[type];
            var    logFile  = new FileInfo(fileName);

            UnityEngine.Debug.AssertFormat(logFile.Exists, "Logfile {0} has to exist", fileName);

            // 0 size means, do not rotate
            if (LogRotateSize > 0 && logFile.Length >= 1024 * LogRotateSize)
            {
                logFile.Archive();
            }
        }
Esempio n. 8
0
        public void AddCallback(Guid key, LoggerLogLevel level, IDiagnosticsServiceCallback callback)
        {
            lock (ConnectedClientLogLevels)
            {
                if (ConnectedClientLogLevels.ContainsKey(key))
                {
                    ConnectedClientLogLevels.Remove(key);
                }

                ConnectedClientLogLevels.Add(key, level);


                AddCallback(key, callback);
            }
        }
Esempio n. 9
0
        void PostfixStackTrace(ref string message, ref string cmessage, LoggerLogLevel level, UnityEngine.Object context, int depth)
        {
            if (level != LoggerLogLevel.Exception)
            {
                var        myTrace = new StackTrace(true);
                StackFrame myFrame = myTrace.GetFrame(depth + 1);
                if (myFrame != null)
                {
                    var filename = myFrame.GetFileName();
                    if (filename != null)
                    {
                        filename = myFrame.GetFileName().Replace(PathUtility.UnityApplicationPath + "/", "");
                    }
                    else
                    {
                        filename = "<filename unknown>";
                    }
                    var ns         = myFrame.GetMethod().DeclaringType.Namespace;
                    var methodname = myFrame.GetMethod().DeclaringType.Name + "." + myFrame.GetMethod().ToString().Split(new[] { ' ' }, 2)[1];
                    var linenumber = myFrame.GetFileLineNumber();

                    message += string.Format("\n{0}{1}\n{2}{3}\n{4}{5}\n{6}{7}",
                                             "Filename: ", filename,
                                             "Namespace: ", ns,
                                             "Method: ", methodname,
                                             "Line: ", linenumber);

                    var keyStyle = Styles.ListKey;
                    var valStyle = Styles.ListValue;

                    cmessage += string.Format("\n{0}{1}\n{2}{3}\n{4}{5}\n{6}{7}",
                                              "Filename: " + keyStyle, filename + valStyle,
                                              "Namespace: " + keyStyle, ns + valStyle,
                                              "Method: " + keyStyle, methodname + valStyle,
                                              "Line: " + keyStyle, (linenumber + "") + valStyle);
                }
            }
            else
            {
                message += "\n" + ((ExceptionContext)context).Exception.StackTrace;
                // TODO: Color message
                cmessage += "\n" + ((ExceptionContext)context).Exception.StackTrace;
            }
        }
Esempio n. 10
0
 public abstract void WriteLog(LoggerLogLevel level, string logText);
Esempio n. 11
0
 public sealed override void WriteLog(LoggerLogLevel level, string logText)
 {
     Queue.Enqueue(new Tuple <LoggerLogLevel, DateTime, string>(level, DateTime.Now, logText));
 }
Esempio n. 12
0
 public abstract void WriteLog(LoggerLogLevel level, string logText);
Esempio n. 13
0
 protected virtual void BroadcastMessage(LoggerLogLevel level, string logtext)
 {
     var handler = MessageBroadcast;
     handler?.Invoke(level, logtext);
 }
Esempio n. 14
0
        protected virtual void BroadcastMessage(LoggerLogLevel level, string logtext)
        {
            var handler = MessageBroadcast;

            handler?.Invoke(level, logtext);
        }
Esempio n. 15
0
 public abstract void WriteLog(LoggerLogLevel level, DateTime logDateTime, string logText);
Esempio n. 16
0
 public override void WriteLog(LoggerLogLevel level, string logText)
 {
     Trace.WriteLine($"{level}: {logText}");
 }
Esempio n. 17
0
 public override void WriteLog(LoggerLogLevel level, string logText)
 {
     Trace.WriteLine($"{level}: {logText}");
 }