public async Task Invoke(HttpContext context)
        {
            string message;
            string userTraceId = context.Request?.Headers["userTraceId"];

            if (string.IsNullOrEmpty(userTraceId))
            {
                userTraceId = Guid.NewGuid().ToString();
                message     = $"Received a request and created a new TraceId";
            }
            else
            {
                message = $"Received a request with TraceId";
            }

            context.Items["userTraceId"] = userTraceId;

            using (var scope = _services.CreateScope())
            {
                ITraceLogger logger = scope.ServiceProvider.GetRequiredService <ITraceLogger>();
                logger.Log(message);
            }

            await _next(context);
        }
Esempio n. 2
0
        /// <summary>
        /// Default log writer.
        /// </summary>
        /// <param name="message">
        /// Calls originating from DevForce via DebugFns and TraceFns calls will pass a <see cref="TraceMessage"/> to the method.
        /// </param>
        public static void DefaultLogWriter(object message)
        {
            // Log to the default DevForce logger, unless the default logger is the NullLogger
            if (!(DefaultTraceLogger is NullLogger))
            {
                DefaultTraceLogger.Log(message);
            }

            // For convenience, let's also log to the console.
            Debug.WriteLine(message);
        }
Esempio n. 3
0
 public override void AddObject(IModelObject obj)
 {
     base.AddObject(obj);
     logger.Log("Added: " + obj);
 }
 public void Simulate()
 {
     logger.Log("Enter Simulator: " + simulatorName);
     sim.Simulate();
     logger.Log("Exit Simulator: " + simulatorName);
 }