Ejemplo n.º 1
0
        public void Intercept(IInvocation invocation)
        {
            if (!_useDynamicProxyLogs)
            {
                invocation.Proceed();
                return;
            }

            string methodName = invocation.TargetType.Name + "." + invocation.Method.Name;

            var logger = Logger.Current;

            logger.LogInfo("   [DynamicProxy] ON ENTRY " + methodName);

            var serializer = SerializatorBuilder.CreateSerializer(SerializatorType);

            foreach (var arg in invocation.Arguments)
            {
                logger.LogInfo($"   [DynamicProxy] ON ENTRY arg: { serializer.Serialize(arg ?? "[null]")}");
            }

            try
            {
                invocation.Proceed();
                logger.LogInfo($"   [DynamicProxy] ON SUCCESS: {methodName}");
                logger.LogInfo($"   [DynamicProxy] ON SUCCESS result: { serializer.Serialize(invocation.ReturnValue ?? "[null]")}");
            }
            catch (Exception e)
            {
                logger.LogError($"   [DynamicProxy] ON EXCEPTION: {methodName} " + e);
            }

            logger.LogInfo($"   [DynamicProxy] ON EXIT: {methodName}");
        }
Ejemplo n.º 2
0
        public override void OnEntry(MethodExecutionArgs args)
        {
            var logger = Logger.CodeRewritingLogger;

            logger.LogInfo($"   [PostSharp] ON ENTRY: {GetMethodName(args)}");
            var serializer = SerializatorBuilder.CreateSerializer(this.SerializatorType);

            foreach (var arg in args.Arguments)
            {
                logger.LogInfo($"   [PostSharp] ON ENTRY arg: { serializer.Serialize(arg ?? "[null]")}");
            }
        }
Ejemplo n.º 3
0
        public override void OnSuccess(MethodExecutionArgs args)
        {
            var logger = Logger.CodeRewritingLogger;

            logger.LogInfo($"   [PostSharp] ON SUCCESS: {GetMethodName(args)}");

            var serializer = SerializatorBuilder.CreateSerializer(this.SerializatorType);

            logger.LogInfo($"   [PostSharp] ON SUCCESS result: { serializer.Serialize(args.ReturnValue ?? "[null]")}");

            base.OnSuccess(args);
            //MemoryCache.Default.Set(key, args.ReturnValue, new CacheItemPolicy());
        }