Esempio n. 1
0
        public async Task Log(LogLevel logLevel, LogTag tag, string message)
        {
            var request = new RestRequest(Method.POST);

            switch (logLevel)
            {
            case LogLevel.Information:
                break;

            case LogLevel.Warning:
                break;

            case LogLevel.Error:
                break;

            default:
                throw new ArgumentOutOfRangeException(
                          nameof(logLevel),
                          logLevel,
                          $"Remote logger supports only {LogLevel.Information}, {LogLevel.Warning} and {LogLevel.Error} log levels"
                          );
            }

            var body = new JSONObject();

            body.Add("level", logLevel.ToString());
            body.Add("message", message);

            if (tag != null)
            {
                body.Add("tags", tag.toJSON());
            }

            request.AddJsonBody(body.ToString());

            var response = await logClient.ExecuteAsync(request);

            if (response.ErrorException != null)
            {
                throw response.ErrorException;
            }
        }
Esempio n. 2
0
 public async Task LogWarning(LogTag tag, string message)
 {
     await Log(LogLevel.Warning, tag, message);
 }
Esempio n. 3
0
 public async Task LogError(LogTag tag, string message)
 {
     await Log(LogLevel.Error, tag, message);
 }
Esempio n. 4
0
 public async Task LogInformation(LogTag tag, string message)
 {
     await Log(LogLevel.Information, tag, message);
 }