forked from mrhamburg/airbyte.cdk.dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AirbyteLogger.cs
33 lines (25 loc) · 1.08 KB
/
AirbyteLogger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using Airbyte.Cdk.Models;
using Type = Airbyte.Cdk.Models.Type;
namespace Airbyte.Cdk
{
/// <summary>
/// Airbyte Logger
/// </summary>
public class AirbyteLogger
{
public void Log(Level level, string message)
{
var airbyteLogMessage = new AirbyteLogMessage {Level = level, Message = message};
var airbyteMessage = new AirbyteMessage {Type = Type.Log, Log = airbyteLogMessage};
AirbyteEntrypoint.ToConsole(airbyteMessage);
}
public void Fatal(string message) => Log(Level.Fatal, message);
public void Exception(Exception exception) => Log(Level.Error, $"{exception.Message}{Environment.NewLine}{exception.StackTrace}");
public void Error(string message) => Log(Level.Error, message);
public void Warn(string message) => Log(Level.Warn, message);
public void Info(string message) => Log(Level.Info, message);
public void Debug(string message) => Log(Level.Debug, message);
public void Trace(string message) => Log(Level.Trace, message);
}
}