Exemple #1
0
 public LogEntry(LogEntryImportance importance, DateTime dateTime, string colleague, string message)
 {
     DateTime   = dateTime;
     Colleague  = colleague;
     Message    = message;
     Importance = importance.ToString();
     ThreadID   = System.Threading.Thread.CurrentThread.ManagedThreadId;
 }
Exemple #2
0
        public void WriteLog(
            string message, GameEntity playerEntity, GameManager manager,
            LogEntryImportance importance = LogEntryImportance.Default)
        {
            if (message == null)
            {
                return;
            }

            var entry = new LogEntry
            {
                Id         = ++manager.Game.NextLogId,
                Message    = message,
                PlayerId   = playerEntity.Id,
                Tick       = manager.Game.CurrentTick,
                Importance = importance
            };

            playerEntity.Player.LogEntries.Add(entry);
        }
Exemple #3
0
        protected void Log(LogEntryImportance importance, string message, bool logToConsole = false)
        {
            //log to dynamic log viewer
            if (logToConsole)
            {
                Mediator.NotifyColleagues <LogEntry>(MediatorMessages.LogMessage, new LogEntry(importance, DateTime.UtcNow, _name, message));
            }

            //log to file
            switch (importance)
            {
            case LogEntryImportance.Info:
                _logger.Info(message);
                break;

            case LogEntryImportance.Debug:
                _logger.Debug(message);
                break;

            case LogEntryImportance.Error:
                _logger.Error(message);
                break;
            }
        }