Пример #1
0
 /// <summary>
 /// Logs the information.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="message">The message.</param>
 /// <param name="store">The store.</param>
 /// <param name="callerFilePath">The caller file path.</param>
 /// <param name="callerMemberName">Name of the caller member.</param>
 /// <param name="callerLineNumber">The caller line number.</param>
 /// <param name="exception">The exception.</param>
 public static void LogInformation(this IRecorderLogger logger,
                                   string message,
                                   string store,
                                   string callerFilePath,
                                   string callerMemberName,
                                   int callerLineNumber,
                                   Exception exception = null) =>
 logger?.Log(LogLevel.Information,
             $"{message} Store '{store}' for '{callerMemberName}' at {callerFilePath}:line {callerLineNumber}", exception);
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Cassette" /> class.
 /// </summary>
 /// <param name="store">The underlying store for this cassette.</param>
 /// <param name="defaultOptions">The default options.</param>
 /// <param name="keyGenerator">The key generator resolver.</param>
 /// <param name="logger">The logger.</param>
 /// <param name="disposeStore">if set to <c>true</c> the cassette will dispose the store when it is disposed.</param>
 /// <exception cref="ArgumentNullException">store</exception>
 public Cassette(
     ICassetteStore store,
     CassetteOptions defaultOptions = null,
     KeyGenerator keyGenerator      = null,
     IRecorderLogger logger         = null,
     bool disposeStore = false)
 {
     Store = store ?? throw new ArgumentNullException(nameof(store));
     // Overwrite default options, preventing the Mode from ever being CassetteOptions.Default
     DefaultOptions = CassetteOptions.Default & defaultOptions;
     KeyGenerator   = keyGenerator ?? FullRequestKeyGenerator.Instance;
     Logger         = logger;
     _disposeStore  = disposeStore;
 }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Cassette" /> class.
        /// </summary>
        /// <param name="filePath">The file path.</param>
        /// <param name="defaultOptions">The default options.</param>
        /// <param name="keyGenerator">The key generator resolver.</param>
        /// <param name="logger">The logger.</param>
        public Cassette(
            string filePath,
            CassetteOptions defaultOptions = null,
            KeyGenerator keyGenerator      = null,
            IRecorderLogger logger         = null)
            : this(
#pragma warning disable DF0000 // Marks undisposed anonymous objects from object creations.
                new FileStore(filePath),
#pragma warning restore DF0000 // Marks undisposed anonymous objects from object creations.
                defaultOptions,
                keyGenerator,
                logger,
                true)
        {
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Cassette" /> class, with storage provided
        /// by a <see cref="FileStore">single file</see> located alongside the caller source file.
        /// </summary>
        /// <param name="defaultOptions">The default options.</param>
        /// <param name="keyGenerator">The key generator resolver.</param>
        /// <param name="logger">The logger.</param>
        /// <param name="callerFilePath">The caller name; set automatically, leave as <see langword="null" />.</param>
        public Cassette(
            CassetteOptions defaultOptions         = null,
            KeyGenerator keyGenerator              = null,
            IRecorderLogger logger                 = null,
            [CallerFilePath] string callerFilePath = "")
            : this(
#pragma warning disable DF0000 // Marks undisposed anonymous objects from object creations.
                new FileStore(Path.Combine(
                                  Path.GetDirectoryName(callerFilePath),
                                  Path.GetFileNameWithoutExtension(callerFilePath) + "_cassette" + FileStore.DefaultExtension)),
#pragma warning restore DF0000 // Marks undisposed anonymous objects from object creations.
                defaultOptions,
                keyGenerator,
                logger,
                true)
        {
        }
Пример #5
0
 /// <summary>
 /// Logs the critical.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="exception">The exception.</param>
 public static void LogCritical(this IRecorderLogger logger, Exception exception) =>
 logger?.Log(LogLevel.Critical, null, exception);
Пример #6
0
 /// <summary>
 /// Logs the error.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="exception">The exception.</param>
 public static void LogError(this IRecorderLogger logger, Exception exception) =>
 logger?.Log(LogLevel.Error, null, exception);