/// <summary> /// Log information (parameters & return value) /// </summary> /// <param name="logger">Logger object to use</param> /// <param name="logLocation">Standard location</param> /// <param name="logLevel">Log level</param> /// <param name="logInfo">Log information holder</param> protected void Log(ILog logger, LogStandardLocation logLocation, LogLevel logLevel, LogInfo logInfo) { try { //============================================================== // Append standard location to parameters //============================================================== if (logger == null) { throw new ArgumentNullException("Logger", "Logger cannot be a null reference"); } else { AppendStandardLocation(logInfo, logLocation); //============================================================== // Log method info in the requested level //============================================================== LogMessageByLevel(logger, logInfo.ToString(), logLevel); } } catch (Exception exception) { //============================================================== // Handle logging error //============================================================== HandleLoggingError(exception); } }
/// <summary> /// Appends the standard location. /// </summary> /// <param name="logInfo">Obj log info.</param> /// <param name="location">Enm location.</param> protected static void AppendStandardLocation(LogInfo logInfo, LogStandardLocation location) { //============================================================== // Add standard socation //============================================================== if (logInfo == null) { throw new ArgumentNullException("logInfo", "logInfo cannot be a null reference"); } else { logInfo.InsertFirst(new LogParameter("Location", location.ToString())); } }
/// <summary> /// Appends the method properties. /// </summary> /// <param name="logInfo">Obj log info.</param> /// <param name="callingMethod">Obj calling method.</param> protected void AppendMethodProperties(LogInfo logInfo, MethodBase callingMethod) { //============================================================== // Add method's name //============================================================== if (logInfo == null) { throw new ArgumentNullException("loginfo", "Location can not be null"); } else { logInfo.InsertFirst(new LogParameter("Method", callingMethod.Name)); } }
/// <summary> /// Logs any free log info in Warning level /// </summary> /// <param name="logInfo">Logging information</param> public void WarnLog(LogInfo logInfo) { //============================================================== // Log Method Entry (Warn Level) //============================================================== Log(mobjActiveLogger, LogLevel.Warn, logInfo); }
/// <summary> /// Logs a method's exit including parameter values /// </summary> /// <param name="logInfo">Logging information</param> public void LogMethodExit(LogInfo logInfo) { //============================================================== // Log Method Entry (Debug Level) //============================================================== Log(mobjActiveLogger, LogStandardLocation.MethodExit, LogLevel.Debug, logInfo); }
/// <summary> /// Logs a method's critical point including parameter values /// </summary> /// <param name="logger">Logger object to use</param> /// <param name="callingMethod">Calling method reflection</param> /// <param name="logInfo">Logging information</param> public void LogMethodCriticalPoint(ILog logger, MethodBase callingMethod, LogInfo logInfo) { //============================================================== // Append method name to parameters //============================================================== AppendMethodProperties(logInfo, callingMethod); //============================================================== // Log Method Entry (Debug Level) //============================================================== Log(logger, LogStandardLocation.MethodCriticalPoint, LogLevel.Debug, logInfo); }
/// <summary> /// Logs any free log info in Info level /// </summary> /// <param name="logInfo">Logging information</param> public void InfoLog(LogInfo logInfo) { //============================================================== // Log Method Entry (Info Level) //============================================================== Log(mobjActiveLogger, LogLevel.Info, logInfo); }
/// <summary> /// Logs any free log info in Debug level /// </summary> /// <param name="logInfo">Logging information</param> public void DebugLog(LogInfo logInfo) { //============================================================== // Log Method Entry (Debug Level) //============================================================== Log(mobjActiveLogger, LogLevel.Debug, logInfo); }