/// <summary> /// 记录日志 /// </summary> /// <param name="operationName"></param> /// <param name="callTime"></param> /// <param name="cost"></param> /// <param name="contextID"></param> /// <param name="methodInfo"></param> /// <param name="inputs"></param> /// <param name="outputs"></param> /// <param name="retValue"></param> public static void Log(string operationName, DateTime callTime, long cost, string contextID, MethodInfo methodInfo, object[] inputs, object[] outputs, object retValue) { LogObject log = new LogObject() { OperationName = operationName, CallTime = callTime, Cost = cost, ContextID = contextID, RetValue = retValue, }; log.CustomerNo = GetCustomerNo(methodInfo, inputs); log.Inputs = GetParamInfo(methodInfo.GetParameters().Where(pi => !pi.IsOut), inputs); log.Outputs = GetParamInfo(methodInfo.GetParameters().Where(pi => pi.IsOut), outputs); WriteLog(log); }
/// <summary> /// 实际写入日志 /// </summary> /// <param name="log"></param> public static void WriteLog(LogObject log) { Console.Out.WriteLine((new JavaScriptSerializer()).Serialize(log)); }