Esempio n. 1
0
        public void AssertThat_Exceptions_CanBeConvertedToJson()
        {
            ILogOutputStream <Object> outputStream = JsonLogOutput.CreateLogOutputStream(
                new GenericOutputStream <String>(log => _testOutputHelper.WriteLine(log))
                );

            using var logger = new OutputLogger(outputStream);

            try
            {
                throw new Exception("test");
            }
            catch (Exception ex)
            {
                logger.LogError(new EventId(0, ""), new { }, ex);
            }
        }
 public ConverterOutputStream(ILogOutputStream <TOutput> outputStream, Func <TInput, TOutput> converter)
 {
     OutputStream = outputStream ?? throw new ArgumentNullException(nameof(outputStream), $"'{nameof(outputStream)}' is not allowed to be null.");
     Converter    = converter ?? throw new ArgumentNullException(nameof(converter), $"'{nameof(converter)}' is not allowed to be null.");
 }
Esempio n. 3
0
 public static ILogOutputStream <Object> CreateLogOutputStream(ILogOutputStream <String> outputStream, JsonSerializerSettings settings = null) =>
 new ConverterOutputStream <Object, String>(
     outputStream,
     it => JsonConvert.SerializeObject(it, settings ?? DefaultSettings)
     );
Esempio n. 4
0
 public OutputLogger(ILogOutputStream <LogEntry> outputStream)
 {
     OutputStream = outputStream;
 }