Exemplo n.º 1
0
            public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter)
            {
                if (!IsEnabled(logLevel))
                {
                    return;
                }

                if (formatter != null)
                {
                    LogHistory.Add(formatter(state, exception));
                }
                else
                {
                    if (state != null)
                    {
                        LogHistory.Add($"{DateTime.Now:s} [{logLevel.ToString()}]: {state}");
                    }

                    if (exception != null)
                    {
                        LogHistory.Add($"{DateTime.Now:s} [{logLevel.ToString()}] Exception Details: {exception.ToString().PadLeft(512, ' ').Substring(0, 511)}");
                    }
                }

                //cleanup LogHistory
                if (LogHistory.Count > 9999)
                {
                    for (var i = 0; i < 1000; i++)
                    {
                        LogHistory.RemoveAt(0);
                    }
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// Logs the command, adding it to the log history and triggers an event
        /// </summary>
        /// <param name="command"></param>
        /// <param name="color"></param>
        private static void LogCommand(string command, string color)
        {
            DebugLogItem item = new DebugLogItem(command, color, Time.frameCount, Time.time, 3, true);

            LogHistory.Add(item);
            MMDebugLogEvent.Trigger(new DebugLogItem(null, "", Time.frameCount, Time.time, 0, false));
        }
Exemplo n.º 3
0
 public void LogWillPowerChanged(string name, int oldValue, int newValue)
 {
     if (oldValue > newValue)
     {
         LogHistory.Add(new Log($"{name}'s Willpower has decremented from {oldValue} to {newValue}"));
     }
     else if (newValue > oldValue)
     {
         LogHistory.Add(new Log($"{name}'s Willpower has incremented from {oldValue} to {newValue}"));
     }
 }
Exemplo n.º 4
0
 public void LogTurnChange(int newTurn, int previousTurn)
 {
     if (newTurn > previousTurn)
     {
         LogHistory.Add(new Log($"Incremented to turn {newTurn}"));
     }
     else if (newTurn < previousTurn)
     {
         LogHistory.Add(new Log($"Decremented to turn {newTurn}"));
     }
 }
Exemplo n.º 5
0
 public void LogObsessionPointsChanged(string name, int obsOldPts, int obsNewPts)
 {
     if (obsOldPts > obsNewPts)
     {
         LogHistory.Add(new Log(
                            $"{name} has lost {obsOldPts - obsNewPts} Obsession Point{(obsOldPts - obsNewPts == 1 ? "" : "s")}"));
     }
     else if (obsNewPts > obsOldPts)
     {
         LogHistory.Add(new Log(
                            $"{name} has earned {obsNewPts - obsOldPts} Obsession Point{(obsOldPts - obsNewPts == 1 ? "" : "s")}"));
     }
 }
Exemplo n.º 6
0
        public void LogDiceRoll(int[] rolls, int modifier)
        {
            var output = rolls.Length switch
            {
                0 => throw new NotImplementedException(),
                      1 => $"{rolls.Length} dice rolled: {rolls.Sum() + modifier}",
                      _ => $"{rolls.Length} dice rolled: {string.Join(", ", rolls)} for a total of {rolls.Sum() + modifier}"
            };

            if (modifier != 0)
            {
                output += $" ({modifier:+#;-#} modifier)";
            }

            LogHistory.Add(new Log(output));
        }
Exemplo n.º 7
0
 public void LogObsessionNameChanged(string name, string oldValue, string newValue)
 {
     LogHistory.Add(new Log($"{name}'s Obsession, {oldValue}, has been renamed to {newValue}"));
 }
Exemplo n.º 8
0
 public void LogNameChanged(string oldName, string newName)
 {
     LogHistory.Add(new Log($"{oldName} has been renamed to {newName}"));
 }
Exemplo n.º 9
0
 public void LogClearInventory()
 {
     LogHistory.Add(new Log("All items have been removed from the inventory"));
 }
Exemplo n.º 10
0
 public void LogItemDescriptionChanged(string name)
 {
     LogHistory.Add(new Log($"Item {name}'s description has been changed"));
 }
Exemplo n.º 11
0
 public void LogAddVoice(VoiceModel voice)
 {
     LogHistory.Add(new Log($"{voice.Name} has been added to the game"));
 }
Exemplo n.º 12
0
 public void LogAddItem(ItemModel item)
 {
     LogHistory.Add(new Log($"{item.Name} has been added to the inventory"));
 }
Exemplo n.º 13
0
 public OutputLogger()
 {
     LogHistory.Add(new Log("This application is ready..."));
     LogHistory.Add(new Log("This log will track all actions you take..."));
 }
Exemplo n.º 14
0
 public void LogDataSave(string fileName, bool errorFlag)
 {
     LogHistory.Add(new Log(errorFlag
         ? "There was an error saving the file. File was not saved..."
         : $"File {fileName} has been successfully saved"));
 }
Exemplo n.º 15
0
 public void LogDataLoad(bool errorFlag)
 {
     LogHistory.Add(new Log(errorFlag
         ? "File has been loaded. There were issues loading some data"
         : "File has been successfully loaded"));
 }
Exemplo n.º 16
0
 public void LogObsessionLevelChanged(string name, int oldValue, int newValue)
 {
     LogHistory.Add(
         new Log($"{name}'s Obsession has been changed from Lv. {oldValue} to Lv. {newValue}"));
 }
Exemplo n.º 17
0
 public void LogSkillNameChanged(string name, string oldName, string playerName)
 {
     LogHistory.Add(new Log($"{name}'s Skill \"{oldName}\" has been changed to \"{name}\""));
 }
Exemplo n.º 18
0
 public void LogRemoveVoice(VoiceModel voice)
 {
     LogHistory.Add(new Log($"{voice.Name} has been removed from the game"));
 }
Exemplo n.º 19
0
 public void AddHistory(string text, Color color = default(Color))
 {
     index = LogHistory.Count;
     LogHistory.Add(text);
 }
Exemplo n.º 20
0
 public void LogClearedVoiceCollection()
 {
     LogHistory.Add(new Log("All voices have been removed from the game"));
 }
Exemplo n.º 21
0
 public void LogRemoveInventoryItem(ItemModel item)
 {
     LogHistory.Add(new Log($"{item.Name} has been removed to the inventory"));
 }
Exemplo n.º 22
0
 public void LogItemCountChanged(string name, int oldCount, int newCount)
 {
     LogHistory.Add(new Log($"Item {name}'s count has been changed from {oldCount} to {newCount}"));
 }