Exemplo n.º 1
0
 /// <summary>
 /// Returns the name of the trace file. Each request is associated with a Tracing GUID, returns this guid.
 /// </summary>
 internal static string GetRequestTraceFile(IServiceProvider serviceProvider)
 {
     var traceLevel = serviceProvider.GetRequiredService<IDeploymentSettingsManager>().GetTraceLevel();
     if (traceLevel <= TraceLevel.Off) return null;
     var contextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
     var httpContext = contextAccessor.HttpContext;
     return TraceServices.GetRequestTraceFile(httpContext);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Returns the ILogger object to log deployments
 /// </summary>
 internal static ILogger GetDeploymentLogger(IServiceProvider serviceProvider)
 {
     var environment = serviceProvider.GetRequiredService<IEnvironment>();
     var level = serviceProvider.GetRequiredService<IDeploymentSettingsManager>().GetTraceLevel();
     var contextAccessor = serviceProvider.GetRequiredService<IHttpContextAccessor>();
     var httpContext = contextAccessor.HttpContext;
     var requestTraceFile = TraceServices.GetRequestTraceFile(httpContext);
     if (level <= TraceLevel.Off || requestTraceFile == null) return NullLogger.Instance;
     var textPath = Path.Combine(environment.DeploymentTracePath, requestTraceFile);
     return new TextLogger(textPath);
 }
Exemplo n.º 3
0
        public static string GetRequestTraceFile(IServiceProvider serviceProvider)
        {
            var traceLevel = serviceProvider.GetRequiredService <IDeploymentSettingsManager>().GetTraceLevel();

            // CORE TODO Need TraceServices implementation - Done , Testing left
            if (traceLevel <= TraceLevel.Off)
            {
                return(null);
            }
            var contextAccessor = serviceProvider.GetRequiredService <IHttpContextAccessor>();
            var httpContext     = contextAccessor.HttpContext;

            return(TraceServices.GetRequestTraceFile(httpContext));
        }
Exemplo n.º 4
0
        public static ITracer GetTracer(IServiceProvider serviceProvider)
        {
            var environment      = serviceProvider.GetRequiredService <IEnvironment>();
            var level            = serviceProvider.GetRequiredService <IDeploymentSettingsManager>().GetTraceLevel();
            var contextAccessor  = serviceProvider.GetRequiredService <IHttpContextAccessor>();
            var httpContext      = contextAccessor.HttpContext;
            var requestTraceFile = TraceServices.GetRequestTraceFile(httpContext);

            if (level <= TraceLevel.Off || requestTraceFile == null)
            {
                return(NullTracer.Instance);
            }
            var textPath = Path.Combine(environment.TracePath, requestTraceFile);

            return(new CascadeTracer(new XmlTracer(environment.TracePath, level), new TextTracer(textPath, level), new ETWTracer(environment.RequestId, TraceServices.GetHttpMethod(httpContext))));
        }