Esempio n. 1
0
        /// <inheritdoc/>
        public void Log(object entry)
        {
            if (!IsOutputEnabled)
            {
                return;
            }

            LogEntry logEntry = StdJsonLogging.NormalizeToLogEntry(entry, SerializerSource);

            string dotNetTypePrefix = logEntry.DotNetType == null ? string.Empty : $"{logEntry.DotNetType}: ";

            WriteLine(
                $"{logEntry.Instant.InZone(_localZone):hh:mm:ss.f}: {dotNetTypePrefix}{logEntry.Message}");

            if (logEntry.Exception != null)
            {
                var baseIntent = "  |";
                Write(baseIntent);
                WriteLine(
                    "------------------------------------- Exception ---------------------------------------");
                string       intent       = string.Empty;
                ExceptionDto curException = logEntry.Exception;
                do
                {
                    Write(baseIntent);
                    Write(intent);
                    if (intent != string.Empty)
                    {
                        Write("<--");
                    }

                    string name = curException.TypeFullName?.Split('.')?.Last() ?? "NullName";
                    WriteLine($"{name}: {curException.Message}");
                    curException = curException.InnerException;
                    intent      += "    ";
                }while (curException != null);

                Write(baseIntent);
                WriteLine(
                    "---------------------------------------------------------------------------------------");
            }
        }
Esempio n. 2
0
        /// <inheritdoc/>
        public void Log(object entry)
        {
            string entryString = StdJsonLogging.NormalizeToString(entry, SerializerSource);

            File.AppendAllLines(_fileName, new[] { entryString }, EncodingEx.UTF8NoBom);
        }