Exemple #1
0
        public void WriteLine(LogLevel level, string format, Color?color = null, params object[] bindings)
        {
            IRocketSettingsProvider rocketSettings = container.Resolve <IRocketSettingsProvider>();
            Color orgCol = ConsoleLogger.GetForegroundColor();

            SetForegroundColor(Color.White);
            System.Console.Write("[");

            SetForegroundColor(BaseLogger.GetLogLevelColor(level));
            System.Console.Write(BaseLogger.GetLogLevelPrefix(level));

            SetForegroundColor(Color.White);
            System.Console.Write("] ");

            if (rocketSettings?.Settings.Logging.IncludeMethods ?? true)
            {
                SetForegroundColor(Color.White);
                System.Console.Write("[");

                SetForegroundColor(Color.DarkGray);
                System.Console.Write(GetLoggerCallingMethod().GetDebugName());

                SetForegroundColor(Color.White);
                System.Console.Write("] ");
            }

            SetForegroundColor(color ?? Color.White);

            string line = string.Format(format, bindings);

            System.Console.WriteLine(line);

            SetForegroundColor(orgCol);
        }