Ejemplo n.º 1
0
        public void OnException(ExceptionContext actionExecutedContext)
        {
            var logContext = WebLoggerModule.GetCurrentLogContext();

            if (logContext == null ||
                !CheckNamespace(actionExecutedContext.Controller.GetType()))
            {
                return;
            }

            logContext.SetLogLevel(LogLevel.Error);
            logContext.AddException(actionExecutedContext.Exception);
        }
Ejemplo n.º 2
0
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            var logContext = WebLoggerModule.GetCurrentLogContext();

            if (logContext == null ||
                !CheckNamespace(filterContext.ActionDescriptor.ControllerDescriptor.ControllerType))
            {
                return;
            }

            logContext.EnableLogging();

            logContext.AddRequestInfo(CommonRequestInfoKeys.Controller,
                                      filterContext.ActionDescriptor.ControllerDescriptor.ControllerName);
            logContext.AddRequestInfo(CommonRequestInfoKeys.Action,
                                      filterContext.ActionDescriptor.ActionName);

            bool requestContentEnabled = true;
            var  param = filterContext.ActionDescriptor.GetParameters();

            if (param != null && param.Length > 0)
            {
                requestContentEnabled = param.All(p => CanTraceRequestType(p.ParameterType));
            }

            if (requestContentEnabled)
            {
                logContext.EnableRequestContentTracing();
            }

            if (CanTraceResponse)
            {
                var responseContentEnabled = true;
                var refActionDescriptor    = filterContext.ActionDescriptor as ReflectedActionDescriptor;
                if (refActionDescriptor != null)
                {
                    responseContentEnabled = CanTraceResponseType(refActionDescriptor.MethodInfo.ReturnType);
                }

                if (responseContentEnabled)
                {
                    logContext.EnableResponseContentTracing();
                }
            }
        }
Ejemplo n.º 3
0
        public void OnException(HttpActionExecutedContext actionExecutedContext)
        {
            var logContext = WebLoggerModule.GetCurrentLogContext();

            if (logContext == null ||
                !CheckNamespace(actionExecutedContext.ActionContext.ActionDescriptor.ControllerDescriptor.ControllerType))
            {
                return;
            }

            logContext.SetLogLevel(LogLevel.Error);
            logContext.AddException(actionExecutedContext.Exception);

            //if (actionExecutedContext.ExceptionHandled)
            //    return;

            //(new RollbarClient()).SendException(filterContext.Exception);
        }
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            var logContext = WebLoggerModule.GetCurrentLogContext();

            if (logContext == null)
            {
                return;
            }

            if (LogLevel != Logging.LogLevel.Off)
            {
                logContext.SetLogLevel(LogLevel);
            }
            if (TraceRequestContent)
            {
                logContext.EnableRequestContentTracing();
            }
            if (TraceResponseContent)
            {
                logContext.EnableResponseContentTracing();
            }
        }
Ejemplo n.º 5
0
        public override void OnAuthorization(HttpActionContext actionContext)
        {
            var logContext = WebLoggerModule.GetCurrentLogContext();

            if (logContext == null ||
                !CheckNamespace(actionContext.ActionDescriptor.ControllerDescriptor.ControllerType))
            {
                return;
            }

            logContext.EnableLogging();

            logContext.AddRequestInfo(CommonRequestInfoKeys.Controller,
                                      actionContext.ControllerContext.ControllerDescriptor.ControllerName);
            logContext.AddRequestInfo(CommonRequestInfoKeys.Action,
                                      actionContext.ActionDescriptor.ActionName);

            bool requestContentEnabled = true;
            var  param = actionContext.ActionDescriptor.GetParameters();

            if (param != null && param.Count > 0)
            {
                requestContentEnabled = param.All(p => CanTraceType(p.ParameterType));
            }

            if (requestContentEnabled)
            {
                logContext.EnableRequestContentTracing();
            }

            if (CanTraceType(actionContext.ActionDescriptor.ReturnType))
            {
                logContext.EnableResponseContentTracing();
            }

            base.OnAuthorization(actionContext);
        }