using System;
using System.IO;
using Volpe.Cafe.IO.DSV;

namespace Volpe.Cafe.Logging
{
    /// <summary>
    /// Provides the class that supports generating of the various diagnostic and debugging logs.
    /// </summary>
    [Serializable]
    public class LogFileWriter : DsvWriter
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="LogFileWriter"/> class for the specified file, using the
        /// default encoding and buffer size. If the file exists, it will be appended to if <paramref name="headers"/>
        /// is <c>null</c>; otherwise, it will be overwritten. If the file does not exist, this constructor creates a
        /// new file. When a new file is created, the specified <paramref name="headers"/> will be written to the file.
        /// When a file is opened in append mode, the headers will be read from the existing file.
        /// </summary>
        /// <param name="path">The complete file path to write to.</param>
        /// <param name="headers">
        ///     An array of column headers to write to the log file, or null, if appending an existing file.
        /// </param>
        /// <exception cref="ArgumentNullException">headers array is null and file is not being appended.</exception>
        /// <exception cref="ArgumentException">headers array is empty and file is not being appended.</exception>
        /// <inheritdoc cref="StreamWriter(string, bool)" path="/exception"/>
        public LogFileWriter(string path, string[] headers)
            : base(path, headers, LogFile.Delimiter, DsvFile.NullChar, LogFile.NewLine) { }

    }
}
