예제 #1
0
        /// <summary>
        /// Constructor LogFileWriter
        /// </summary>
        public LogFileWriter(
            FileParameterStruct fileParameter,
            Func <string>?getNewFileHeader     = null,
            Func <string>?getNewDayHeader      = null,
            int maxMessageQueueSize            = maxMessageQueueSizeDefault,
            int logFileWriterTimerInitialDelay = 10,
            int logFileWriterTimerInterval     = 10000)
        {
            this.getNewFileHeader    = getNewFileHeader;
            this.getNewDayHeader     = getNewDayHeader;
            this.maxMessageQueueSize = maxMessageQueueSize;
            fileSizeManager          = new FileSizeManager(fileParameter);

            initialiseLogFileWriterTimer(logFileWriterTimerInitialDelay, logFileWriterTimerInterval);
        }
예제 #2
0
        void initialiseNewParameter()
        {
            FileParameterStruct existingFileParameter = fileSizeManager.FileParameter;

            if (existingFileParameter.DirectoryPath == newFileParameter.DirectoryPath &&
                existingFileParameter.FileName == newFileParameter.FileName &&
                existingFileParameter.FileExtension == newFileParameter.FileExtension) //
            {
                //only max size or number of files has changed. Just change some FileSizeManager properties.
                fileSizeManager.ChangeProperties(newFileParameter.MaxFileByteCount, newFileParameter.MaxFileCount);
            }
            else
            {
                //file name or location has changed, a new FileSizeManager is needed.
                fileSizeManager = new FileSizeManager(newFileParameter);
            }
            isNewFileParameter = false;
            lastDate           = DateTime.Now.Date;
        }