/// <summary> /// Creates a new console writer with the plugins load data. /// </summary> /// <param name="logWriterLoadData">The data to load the logwriter with.</param> public ConsoleWriter(LogWriterLoadData logWriterLoadData) : base(logWriterLoadData) { // Get fast ansi coloring setting, defaulting to true. if (logWriterLoadData.Settings["useFastAnsiColoring"] != null) { if (!bool.TryParse(logWriterLoadData.Settings["useFastAnsiColoring"], out useFastAnsiColoring)) { throw new ArgumentException("useFastAnsiColoring setting on ConsoleWriter was not a boolean!"); } } else { useFastAnsiColoring = true; } if (useFastAnsiColoring) { if (!ColorsOnWindows.Enable()) { Console.WriteLine($"Could not enable ANSI coloring on Windows. Consider adding useFastAnsiColoring = false to the {nameof(ConsoleWriter)}'s settings (https://www.darkriftnetworking.com/DarkRift2/Docs/2.9.0/advanced/internal_plugins/console_writer.html):\n" + $"\n" + $"\t<logWriter name=\"{Name}\" type=\"{nameof(ConsoleWriter)}\" levels=\"...\">\n" + $"\t\t<settings useFastAnsiColoring=\"false\" />\n" + $"\t</logWriter>.\n" + $"\n" + $"Last error code was '{ColorsOnWindows.GetLastError()}'. Will continue logging to console with standard coloring methods."); useFastAnsiColoring = false; } } }
/// <summary> /// Creates a new file writer with the given plugin load data. /// </summary> /// <param name="logWriterLoadData">The data for this plugin.</param> public FileWriter(LogWriterLoadData logWriterLoadData) : base(logWriterLoadData) { //Get the log directory concatenated with the date LogFilePath = string.Format(logWriterLoadData.Settings["file"], DateTime.Now); //Create the actual log directory (will do nothing if it already exists) Directory.CreateDirectory(Path.GetDirectoryName(LogFilePath)); //Create the log file and stream for it LogFileStream = new StreamWriter(LogFilePath); }
public UnityConsoleWriter(LogWriterLoadData pluginLoadData) : base(pluginLoadData) { }
public UnityModManagerWriter(LogWriterLoadData pluginLoadData) : base(pluginLoadData) { }
/// <summary> /// Creates a new debug log writer using the given plugin load data. /// </summary> /// <param name="logWriterLoadData">The data for this log writer.</param> public DebugWriter(LogWriterLoadData logWriterLoadData) : base(logWriterLoadData) { }
/// <summary> /// Constructor. Called as the log writer is loaded. /// </summary> public LogWriter1(LogWriterLoadData logWriterLoadData) : base(logWriterLoadData) { }