public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) { var id = Guid.NewGuid(); //调试状态 //if (log.IsDebugEnabled) //{ // var info = new // { // id = id, // @object = input.Target.GetType().Name, // method = input.MethodBase.Name, // args = input.Arguments, // }; // log.Debug("[函数调用]" + JsonConvert.SerializeObject(info)); //} var result = getNext()(input, getNext); try { if (result.Exception != null && (!result.Exception.Data.Contains("IsLoged"))) { var info = new LogEntity() { logger = string.Format("{0}.{1}", input.Target.GetType().Name, input.MethodBase.Name), module = "ExceptionCallHandler", msg = string.Format("[返回值]:{0}", JsonConvert.SerializeObject(result.ReturnValue)), param = JsonConvert.SerializeObject(input.Arguments) }; //var expLog = LogManager.GetLogger(input.Target.GetType()); //log.Debug(JsonConvert.SerializeObject(input.Arguments)); log.Error(info, result.Exception); result.Exception.Data.Add("IsLoged", true); } } catch { } ////调试状态 //if (log.IsDebugEnabled) //{ // var info = new // { // id = id, // @object = input.Target.GetType().Name, // method = input.MethodBase.Name, // result = result.ReturnValue, // output = result.Outputs, // }; // log.Debug("[返回值]" + JsonConvert.SerializeObject(info)); //} return result; }
public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) { //var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data"); //var fileMap = Path.Combine(path, "CatConfig.xml"); //Cat.Initialize(fileMap); var a = Cat.GetProducer().NewTransaction("WorkFlowService", input.MethodBase.Name); string beginDate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff"); var watcher = new Stopwatch(); watcher.Start(); Cat.GetProducer().LogEvent("WorkFlowService", "Arguments", "0", JsonConvert.SerializeObject(input.Arguments)); var result = getNext()(input, getNext); Cat.GetProducer().LogEvent("WorkFlowService", "ReturnValue", "0", JsonConvert.SerializeObject(result.ReturnValue)); string param = string.Empty; string logger = string.Empty; try { logger = string.Format("{0}.{1}", input.Target.GetType().Name, input.MethodBase.Name); param = JsonConvert.SerializeObject(new { BeginDate = beginDate, Input = input.Arguments, ReturnValue = result.ReturnValue }); } catch { } var info = new LogEntity() { logger = logger, module = "PerformanceCallHandler", param = param }; watcher.Stop(); if (result.Exception != null) { Cat.GetProducer().LogError(result.Exception); a.SetStatus(result.Exception); } else { a.Status = "0"; } a.Complete(); info.msg = string.Format("{0}", watcher.ElapsedMilliseconds); log.Info(info); return result; }
public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) { Cat.GetProducer().NewTransaction(input.Target.GetType().Name, input.MethodBase.Name); var a = Cat.GetManager().PeekTransaction; var result = getNext()(input, getNext); if (result.Exception != null) { Cat.GetProducer().LogEvent(input.MethodBase.Name, "Arguments", "0", JsonConvert.SerializeObject(input.Arguments)); Cat.GetProducer().LogError(result.Exception); a.SetStatus(result.Exception); if (log.IsErrorEnabled) { string logger = string.Empty; string param = string.Empty; try { logger = string.Format("{0}.{1}", input.Target.GetType().Name, input.MethodBase.Name); param = JsonConvert.SerializeObject(new { Input = input.Arguments, ReturnValue = result.ReturnValue }); } catch { } var info = new LogEntity() { logger = logger, module = "ExceptionCallHandler", msg = result.Exception.Message, param = param }; log.Error(info, result.Exception); } } else { a.Status = "0"; } a.Complete(); return result; }
public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate getNext) { var info = new LogEntity() { logger = string.Format("{0}.{1}", input.Target.GetType().Name, input.MethodBase.Name), module = "PerformanceCallHandler", param = "" }; //var expLog = LogManager.GetLogger(input.Target.GetType()); var watcher = new Stopwatch(); watcher.Start(); var result = getNext()(input, getNext); watcher.Stop(); info.msg = string.Format("[RunTime]:{0}", watcher.ElapsedMilliseconds); log.Info(info); return result; }