public static object SimpleLogger(OperationJoinPoint jp) { GroupName = "GpeSimpleLogger"; LogParameter = true; return ExecutionToLogInternal(jp); }
public static object SampleTarget(OperationJoinPoint jp) { GroupName = "GpeSampleTarget"; LogParameter = true; return ExecutionToLogInternal(jp); }
public static object ShoppingCartOperator(OperationJoinPoint jp) { GroupName = "GpeShoppingCartOperator"; LogParameter = true; return ExecutionToLogInternal(jp); }
public static object Item(OperationJoinPoint jp) { GroupName = "GpeItem"; LogParameter = true; return ExecutionToLogInternal(jp); }
private static object LogIt(OperationJoinPoint jp) { String name = ""; if (wlogInfoEnable) { name = jp.TargetOperation.DeclaringType.FullName + "::" + jp.TargetOperationName; wLOG.Info("Entering " + name); } object result = jp.Proceed(); if (wlogInfoEnable) wLOG.Info("Leaving " + name); return result; }
public static string Log(OperationJoinPoint ojpOperationJoinPoint, object oReturnData) { try { logTargetDir = DI.config.getTempFolderInTempDirectory("o2.AspectDngHook.dll_CallLogs"); Files.checkIfDirectoryExistsAndCreateIfNot(logTargetDir); var sbLogMessage = new StringBuilder(); sbLogMessage.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); sbLogMessage.AppendLine(" <AspectDngTrace"); sbLogMessage.AppendLine(" TargetOperationName=\"" + ojpOperationJoinPoint.TargetOperationName + "\" "); sbLogMessage.AppendLine(" TargetOperation=\"" + ojpOperationJoinPoint.TargetOperation + "\" >"); sbLogMessage.AppendLine(" <Arguments>"); foreach (Object oArgument in ojpOperationJoinPoint.Arguments) sbLogMessage.AppendLine(" <Arguments type=\"" + oArgument.GetType().FullName + "\" value=\"" + oArgument + "\"/>"); sbLogMessage.AppendLine(" </Arguments>"); if (oReturnData == null) sbLogMessage.AppendLine(" <ReturnData/>"); else sbLogMessage.AppendLine(" <ReturnData><![CDATA[ " + oReturnData + " ]]></ReturnData>"); sbLogMessage.AppendLine(" <Thread"); sbLogMessage.AppendLine(" ManagedThreadId=\"" + Thread.CurrentThread.ManagedThreadId + "\""); sbLogMessage.AppendLine(" Name=\"" + Thread.CurrentThread.Name + "\"/>"); sbLogMessage.AppendLine(" <StackTrace><![CDATA["); sbLogMessage.AppendLine(new StackTrace(false) + " ]]></StackTrace>"); sbLogMessage.AppendLine(" </AspectDngTrace>"); return LogToFile(sbLogMessage.ToString()); } catch (Exception ex) { DI.log.ex(ex); return ""; } }
public static object ExecutionToLogInternal(OperationJoinPoint jp) { object result = null; StoreManager storeManager = null; try { if (jp == null) { sLog.Error("Unable to log a null joinpoint"); return result; } storeManager = StoreManager.GetManager(); Object[] tArgs = null; if (logParameter) { // On log les paramètres d'appel, de retour et les exceptions tArgs = jp.Arguments; } if (storeManager != null) { storeManager.LogBeginOfMethod(jp, tArgs, groupName); } else { //sLog.Error("executionToLogInternal Impossible de logger l'entrée de la methode"); } } //Impossible de laisser remonter une erreur de NMonitoring vers l'appli ! // TODO : Voir s'il ne faudrait pas courcircuiter l'appel a LogEndOfMethod //dans le cas ou on arrive pas à logger le debut catch (NMonitoringException e) { sLog.Error("NMonitoringException : Unable to log", e); } catch (Exception e) { sLog.Error("Unknown Exception : Unable to log", e); } try { //Execution du code à auditer result = jp.Proceed(); //Fin normale (sans exception) du code audité try { if (storeManager != null) { if (logParameter) { storeManager.LogEndOfMethodNormal(result); } else { storeManager.LogEndOfMethodNormal(null); } } else { sLog.Error("executionToLogInternal Impossible de logger la sortie de la methode"); } } //Impossible de laisser remonter une erreur de NMonitoring vars l'appli ! catch (NMonitoringException e) { sLog.Error("NMonitoringException : Unable to log", e); } catch (Exception e) { sLog.Error("Unknown Exception : Unable to log", e); } } //Une exception s'est produite dans l'application auditée catch (Exception externalException) { try { //In log la fin de la methode en marquant l'exception storeManager.LogEndOfMethodWithException(externalException); } //Impossible de laisser remonter une erreur de NMonitoring vars l'appli ! catch (NMonitoringException internalException) { sLog.Error("NMonitoringException : Unable to log execution Throwable", internalException); } catch (Exception e) { sLog.Error("Unknown Exception : Unable to log", e); } //On propage l'exception issue de l'application auditée throw; } return result; }
public static object Interceptor(OperationJoinPoint jp) { object result = jp.Proceed(); return result; }
/** * Trace a method with its arguments. * * @param joinPoint The method signature. * @param args The method arguments. * @param groupName The name of the group associated with this <code>MethodCallDTO</code>. */ public void LogBeginOfMethod(OperationJoinPoint joinPoint, Object [] args, String groupName) { if (joinPoint == null) { throw new NMonitoringException("No jointPoint to log"); } string operationName = joinPoint.TargetOperationName; string classeName = joinPoint.TargetOperation.ReflectedType.FullName; // Name ? LogBeginOfMethod(classeName,operationName,args,groupName); }
public static object Intercept(OperationJoinPoint jp) { Console.WriteLine("--- before call : {0}", jp); return jp.Proceed(); }
public static void Log(Exception ex, OperationJoinPoint ojpOperationJoinPoint) { }
public static object AroundBodyFilter(OperationJoinPoint ojpOperationJoinPoint) { //Log("AroundBody:::" + ojpOperationJoinPoint.ToString()); //Log(ojpOperationJoinPoint); try { object oReturnValue = ojpOperationJoinPoint.Proceed(); Log(ojpOperationJoinPoint, oReturnValue); //if (oReturnValue != null) // Log(ojpOperationJoinPoint.TargetOperationName + " returned:" + oReturnValue); return oReturnValue; } catch (Exception ex) { Log(ex, ojpOperationJoinPoint); return null; } }
public static object AroundCallFilter(OperationJoinPoint ojpOperationJoinPoint) { //System.Diagnostics.Debug.WriteLine("AroundCall:" + ojpOperationJoinPoint.ToString()); //Log("AroundCall:" + ojpOperationJoinPoint.ToString()); try { object oReturnValue = ojpOperationJoinPoint.Proceed(); Log(ojpOperationJoinPoint, oReturnValue); //if (oReturnValue != null) // Log(ojpOperationJoinPoint.TargetOperationName + " returned:" + oReturnValue); return oReturnValue; } catch (Exception ex) { Log(ex, ojpOperationJoinPoint); return null; } }