Exemplo n.º 1
0
 /// <summary>
 /// Creates a new instance of the <see cref="FileLoggerProvider"/> class
 /// </summary>
 public FileLoggerProvider(string name, string path, IFileNamingFormat namingFormat, IFileFormat format)
 {
     _name         = name;
     _path         = path;
     _namingFormat = namingFormat;
     _format       = format;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new instance of the <see cref="FileLoggerProvider"/> class
 /// </summary>
 public FileLoggerProvider(string name, DirectoryInfo directory, IFileNamingFormat namingFormat, IFileFormat format)
 {
     _name         = name;
     _directory    = directory;
     _namingFormat = namingFormat;
     _format       = format;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Adds a <see cref="FileLogger"/> instance to the <seealso cref="ILoggingBuilder"/>
        /// </summary>
        /// <param name="name">The name of this log file</param>
        /// <param name="directory">The directory of the log file</param>
        /// <param name="namingFormat">The naming format applied</param>
        /// <param name="format">The format applied</param>
        public static ILoggingBuilder AddFile(this ILoggingBuilder builder, string name, string directory, IFileNamingFormat namingFormat = null, IFileFormat format = null)
        {
            namingFormat ??= FileNamingFormats.Default;
            format ??= FileFormats.Default;

            var dir = new DirectoryInfo(directory);

            Directory.CreateDirectory(dir.FullName);
            var path = Path.Combine(dir.FullName, namingFormat.NameFile(dir, name));

            builder.AddProvider(new FileLoggerProvider(name, path, namingFormat, format));



            return(builder);
        }
Exemplo n.º 4
0
 internal FileLogger(string categoryName, string name, DirectoryInfo directory, IFileFormat format, IFileNamingFormat namingFormat)
 {
     _categoryName = categoryName;
     _format = format;
     _path = Path.Combine(directory.FullName, namingFormat.NameFile(directory, name));
 }
Exemplo n.º 5
0
 internal FileLogger(string categoryName, string path, IFileFormat format, IFileNamingFormat namingFormat)
 {
     _categoryName = categoryName;
     _format       = format;
     _path         = path;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Adds a <see cref="FileLogger"/> instance to the <seealso cref="ILoggingBuilder"/>
        /// </summary>
        /// <param name="name">The name of this log file</param>
        /// <param name="directory">The directory of the log file</param>
        /// <param name="namingFormat">The naming format applied</param>
        /// <param name="format">The format applied</param>
        public static ILoggingBuilder AddFile(this ILoggingBuilder builder, string name, string directory, IFileNamingFormat namingFormat = null, IFileFormat format = null)
        {
            if (namingFormat == null)
            {
                namingFormat = FileNamingFormats.Default;
            }
            if (format == null)
            {
                format = FileFormats.Default;
            }

            builder.AddProvider(new FileLoggerProvider(name, new DirectoryInfo(directory), namingFormat, format));

            return(builder);
        }