Exemplo n.º 1
0
        private ConsoleMessage ToLogMessage(RecordType type, string category, string text, Exception exception)
        {
            switch (type)
            {
            case RecordType.Error:
                return(ConsoleMessage.Error(String.Format("[{0}] {1}:{2}. Exception: {3}", type, category, text, exception)));

            case RecordType.Warn:
                return(ConsoleMessage.Warning(String.Format("[{0}] {1}:{2}", type, category, text)));

            case RecordType.Info:
                var lines  = text.Trim('\n').Split('\n');
                var output = new StringBuilder();
                output.Append(String.Format("[{0}] {1}:", type, category));
                for (var i = 0; i < lines.Length; i++)
                {
                    output.AppendFormat("{0}{1}", lines[i], i != lines.Length - 1 ? "\n" : "");
                }
                return(ConsoleMessage.Info(output.ToString()));

            default:
                return(ConsoleMessage.Debug(String.Format("[{0}] {1}: {2}", type, category, text)));
            }
        }