예제 #1
0
        public static void Log(TES3LogLevel level, string formatString, params object[] args)
        {
            var target = level.GetWriter();

            if (target == null)
            {
                return;
            }

            target.WriteLine($"{level.GetLogIndicator()}: {string.Format(formatString, args)}");
        }
예제 #2
0
        public static void Log(TES3LogLevel level, string message)
        {
            var target = level.GetWriter();

            if (target == null)
            {
                return;
            }

            target.WriteLine(message);
        }
예제 #3
0
        public static string GetLogIndicator(this TES3LogLevel level)
        {
            switch (level)
            {
            case TES3LogLevel.Info:
                return("INFO");

            case TES3LogLevel.Warn:
                return("WARN");

            case TES3LogLevel.Error:
                return("ERROR");
            }

            throw new InvalidOperationException($"Unrecognized log level: {level}");
        }
예제 #4
0
        public static TextWriter GetWriter(this TES3LogLevel level)
        {
            switch (level)
            {
            case TES3LogLevel.Info:
                return(GlobalConfig.InfoWriter);

            case TES3LogLevel.Warn:
                return(GlobalConfig.WarnWriter);

            case TES3LogLevel.Error:
                return(GlobalConfig.ErrorWriter);
            }

            throw new InvalidOperationException($"Unrecognized log level: {level}");
        }