예제 #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;
        }
예제 #2
0
 private void OnLogBroadcast(LoggerLogLevel level, string logtext)
 {
     if ((int)MinLogLevel <= (int)level)
     {
         WriteLog(level, logtext);
     }
 }
예제 #3
0
 private void OnLogBroadcast(LoggerLogLevel level, string logtext)
 {
     if ((int)MinLogLevel <= (int)level)
     {
         WriteLog(level, logtext);
     }
 }
예제 #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);
     }
 }
예제 #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);
     }
 }
예제 #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);
                }
            }
        }
예제 #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();
            }
        }
예제 #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);
            }
        }
예제 #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;
            }
        }
예제 #10
0
 public abstract void WriteLog(LoggerLogLevel level, string logText);
예제 #11
0
 public sealed override void WriteLog(LoggerLogLevel level, string logText)
 {
     Queue.Enqueue(new Tuple <LoggerLogLevel, DateTime, string>(level, DateTime.Now, logText));
 }
예제 #12
0
 public abstract void WriteLog(LoggerLogLevel level, string logText);
예제 #13
0
파일: Logger.cs 프로젝트: Hem/SimpleNet
 protected virtual void BroadcastMessage(LoggerLogLevel level, string logtext)
 {
     var handler = MessageBroadcast;
     handler?.Invoke(level, logtext);
 }
예제 #14
0
파일: Logger.cs 프로젝트: Hem/SimpleNet
        protected virtual void BroadcastMessage(LoggerLogLevel level, string logtext)
        {
            var handler = MessageBroadcast;

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