C# Class BF2Statistics.Logging.LogWriter

Provides an object wrapper for a file that is used to store LogMessage's into. Uses a Multi-Thread safe Queueing system, and provides full Asynchronous writing and flushing
Inheritance: IDisposable
Show file Open project: BF2Statistics/ControlCenter Class Usage Examples

Public Properties

Property Type Description
LoggingEnabled bool

Public Methods

Method Description
ClearLog ( ) : void

Queues the underlying log writer to empty the logfile before appending any more messages to it. Messages that are awaiting to be written to the log file are NOT removed from Queue

Dispose ( ) : void
LogWriter ( string FileLocation, bool Truncate = false, int TruncateLen = 2097152 ) : System

Creates a new Log Writter instance

Write ( string message ) : void

Adds a message to the queue, to be written to the log file

Private Methods

Method Description
FlushLog ( ) : void

Flushes the Queue to the physical log file

Method Details

ClearLog() public method

Queues the underlying log writer to empty the logfile before appending any more messages to it. Messages that are awaiting to be written to the log file are NOT removed from Queue
public ClearLog ( ) : void
return void

Dispose() public method

public Dispose ( ) : void
return void

LogWriter() public method

Creates a new Log Writter instance
public LogWriter ( string FileLocation, bool Truncate = false, int TruncateLen = 2097152 ) : System
FileLocation string The location of the logfile. If the file doesnt exist, /// It will be created.
Truncate bool If set to true and the logfile is over XX size, it will be truncated to 0 length
TruncateLen int /// If is true, The size of the file must be at least this size, /// in bytes, to truncate it ///
return System

Write() public method

Adds a message to the queue, to be written to the log file
public Write ( string message ) : void
message string The message to write to the log
return void

Property Details

LoggingEnabled public property

Gets or sets whether we having logging enabled. If disabled, all invokes to Write() will be ignored
public bool LoggingEnabled
return bool