C# Class CK.Monitoring.MonitorFileOutputBase

Helper class that encapsulates temporary stream and final renaming for log entries streams. This currently handles only the maximum count of entries per file but this may be extended with options like "SubFolderMode" that can be based on current time (to group logs inside timed intermediate folders like one per day: 2014/01/12 or 2014-01/12, etc.).
Inheritance: IDisposable
Exibir arquivo Open project: Invenietis/ck-core

Public Methods

Method Description
Close ( ) : void

Closes the file if it is currently opened. Does nothing otherwise.

Dispose ( ) : void

Simply calls Close.

Initialize ( IActivityMonitor monitor ) : bool

Checks whether this MonitorFileOutputBase is valid: its base path is successfully created. Can be called multiple times.

Protected Methods

Method Description
AfterWrite ( ) : void

This method must be called after write: it closes and produces the final file if the current file is full.

BeforeWrite ( ) : void

This method must be called before any write: it calls OpenNewFile if needed.

CloseCurrentFile ( ) : void

Closes the currently opended file.

MonitorFileOutputBase ( string configuredPath, System.Guid monitorId, int maxCountPerFile, bool useGzipCompression ) : System

Initializes a new file for ILogEntry issued from a specific monitor: the final file name is based on FileUtil.FileNameUniqueTimeUtcFormat with a "-{XXX...XXX}.ckmon" suffix where {XXX...XXX} is the unique identifier (Guid with the B format - 32 digits separated by hyphens, enclosed in braces) of the monitor. You must call Initialize before actually using this object.

MonitorFileOutputBase ( string configuredPath, string fileNameSuffix, int maxCountPerFile, bool useGzipCompression ) : System

Initializes a new file for IMulticastLogEntry: the final file name is based on FileUtil.FileNameUniqueTimeUtcFormat with a ".ckmon" extension. You must call Initialize before actually using this object.

OpenNewFile ( ) : Stream

Opens a new file suffixed by ".tmp".

Private Methods

Method Description
ComputeBasePath ( IActivityMonitor m ) : string

Computes the root path.

Method Details

AfterWrite() protected method

This method must be called after write: it closes and produces the final file if the current file is full.
protected AfterWrite ( ) : void
return void

BeforeWrite() protected method

This method must be called before any write: it calls OpenNewFile if needed.
protected BeforeWrite ( ) : void
return void

Close() public method

Closes the file if it is currently opened. Does nothing otherwise.
public Close ( ) : void
return void

CloseCurrentFile() protected method

Closes the currently opended file.
protected CloseCurrentFile ( ) : void
return void

Dispose() public method

Simply calls Close.
public Dispose ( ) : void
return void

Initialize() public method

Checks whether this MonitorFileOutputBase is valid: its base path is successfully created. Can be called multiple times.
public Initialize ( IActivityMonitor monitor ) : bool
monitor IActivityMonitor Required monitor.
return bool

MonitorFileOutputBase() protected method

Initializes a new file for ILogEntry issued from a specific monitor: the final file name is based on FileUtil.FileNameUniqueTimeUtcFormat with a "-{XXX...XXX}.ckmon" suffix where {XXX...XXX} is the unique identifier (Guid with the B format - 32 digits separated by hyphens, enclosed in braces) of the monitor. You must call Initialize before actually using this object.
protected MonitorFileOutputBase ( string configuredPath, System.Guid monitorId, int maxCountPerFile, bool useGzipCompression ) : System
configuredPath string The path. Can be absolute. When relative, it will be under that must be set.
monitorId System.Guid Monitor identifier.
maxCountPerFile int Maximum number of entries per file. Must be greater than 1.
useGzipCompression bool True to gzip the file.
return System

MonitorFileOutputBase() protected method

Initializes a new file for IMulticastLogEntry: the final file name is based on FileUtil.FileNameUniqueTimeUtcFormat with a ".ckmon" extension. You must call Initialize before actually using this object.
protected MonitorFileOutputBase ( string configuredPath, string fileNameSuffix, int maxCountPerFile, bool useGzipCompression ) : System
configuredPath string The path: it can be absolute and when relative, it will be under (that must be set).
fileNameSuffix string Suffix of the file including its extension. Must not be null nor empty.
maxCountPerFile int Maximum number of entries per file. Must be greater than 1.
useGzipCompression bool True to gzip the file.
return System

OpenNewFile() protected method

Opens a new file suffixed by ".tmp".
protected OpenNewFile ( ) : Stream
return Stream