private static void LogFilters(HttpContext context, IObjectWriter c)
        {
            var app = context.Features.Get <IAppFeature>()?.App;

            if (app != null)
            {
                c.WriteProperty("appId", app.Id.ToString());
                c.WriteProperty("appName", app.Name);
            }

            var userId = context.User.OpenIdSubject();

            if (!string.IsNullOrWhiteSpace(userId))
            {
                c.WriteProperty(nameof(userId), userId);
            }

            var clientId = context.User.OpenIdClientId();

            if (!string.IsNullOrWhiteSpace(clientId))
            {
                c.WriteProperty(nameof(clientId), clientId);
            }

            var costs = context.Features.Get <IApiCostsFeature>()?.Weight ?? 0;

            c.WriteProperty(nameof(costs), costs);
        }
Exemplo n.º 2
0
 private static void InternalWriteException(IObjectWriter writer, Exception exception)
 {
     writer.WriteProperty("message", exception.Message)
     .WriteProperty("type", exception.GetType().FullName)
     .WriteProperty("stacktrace", exception.StackTrace);
     if (exception is AggregateException aggregateException)
     {
         writer.WriteArray("inner_exceptions", array =>
         {
             foreach (Exception innerException in aggregateException.InnerExceptions)
             {
                 array.WriteObject(x => InternalWriteException(x, innerException));
             }
         });
     }
     else if (exception.InnerException != null)
     {
         writer.WriteException(exception.InnerException, "inner_exception");
     }
 }
        public void Append(IObjectWriter writer, SemanticLogLevel logLevel, Exception?exception)
        {
            var severity = GetSeverity(logLevel);

            writer.WriteProperty(nameof(severity), severity);
        }
Exemplo n.º 4
0
 public void Append(IObjectWriter writer, SemanticLogLevel logLevel)
 {
     writer.WriteProperty("timestamp", clock.GetCurrentInstant());
 }
 public void Append(IObjectWriter writer)
 {
     writer.WriteProperty(_fieldName, _timestamp());
 }
Exemplo n.º 6
0
 public void Append(IObjectWriter writer)
 {
     writer.WriteProperty("timestamp", timestamp());
 }
Exemplo n.º 7
0
 public void Append(IObjectWriter writer)
 {
     writer.WriteProperty("timestamp", clock.GetCurrentInstant());
 }
Exemplo n.º 8
0
 void IAuditFormattable.Write(IObjectWriter writer)
 {
     writer.WriteProperty("From", _from);
     writer.WriteProperty("Until", _until);
 }
Exemplo n.º 9
0
 public void Write(IObjectWriter writer)
 {
     writer.WriteProperty("Staff", _staff);
     writer.WriteProperty("Group", _group);
 }
Exemplo n.º 10
0
        public void Should_write_boolean_property()
        {
            var result = sut.WriteProperty("property", true).ToString();

            Assert.Equal(@"{""property"":true}", result);
        }
Exemplo n.º 11
0
 public static IObjectWriter DumpObject(this IObjectWriter writer, string property, object obj)
 {
     return(writer.WriteProperty(property, JsonConvert.SerializeObject(obj)));
 }
Exemplo n.º 12
0
 public static IObjectWriter WriteMessage(this IObjectWriter writer, string message)
 {
     return(writer.WriteProperty("message", message));
 }
Exemplo n.º 13
0
 public void Append(IObjectWriter writer, SemanticLogLevel logLevel, Exception?exception)
 {
     writer.WriteProperty(nameof(category), category);
 }