/// <summary>
        /// Logs method calls to the configured logger using the given format string.
        ///
        /// Method call logging is performed before invocation.
        ///
        /// The format string replaces:
        /// "%method%" with the method signature
        /// "%args%" with a comma-delimited argument list
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="proxii"></param>
        /// <param name="logLevel">The NLog level to log the message to. Defaults to LogLevel.Info</param>
        /// <param name="format">The format string to use to generate the message</param>
        /// <returns></returns>
        public static IProxii <T> LogCalls <T>(this IProxii <T> proxii, LogLevel logLevel, string format)
            where T : class
        {
            var logger = typeof(T).GetLogger();

            if (string.IsNullOrWhiteSpace(format))
            {
                logger.Log(LogLevel.Warn, "LogCalls() provided with empty or null format string");
                return(proxii);
            }


            var nlogFormat = format.Replace("%method%", "{0}")
                             .Replace("%args%", "{1}");

            return(proxii.BeforeInvoke(CreateLogCallsAction(logger, logLevel, nlogFormat)));
        }
Beispiel #2
0
 /// <summary>
 /// Logs a JSON object on interception in varying detail levels (https://github.com/zckeyser/proxii-nlog/wiki/LogCallsObject)
 /// </summary>
 public static IProxii <T> LogCallsObject <T>(this IProxii <T> proxii, LogLevel logLevel, LogDetailLevel detailLevel = LogDetailLevel.Low)
     where T : class
 {
     return(proxii.BeforeInvoke(CreateLogCallsObjectAction(typeof(T).GetLogger(), logLevel, detailLevel)));
 }