Simply3DScan
Logging.LoggerTask Class Reference

Task for logging events More...

Public Member Functions

 LoggerTask (string folder, string fileName)
 Initializes a new instance of the LoggerTask class. More...
 
void DoWork ()
 Does the work. Events to log are filled in a concurrent queue and then read here in serial order. More...
 

Package Functions

void EnqueueObject (LoggerInfo loggerInfo)
 Enqueues the object. More...
 
void Stop ()
 Stops this instance. More...
 

Properties

bool IsStopped [get]
 Gets a value indicating whether this instance is stopped. More...
 

Detailed Description

Task for logging events

Definition at line 10 of file LoggerTask.cs.

Constructor & Destructor Documentation

Logging.LoggerTask.LoggerTask ( string  folder,
string  fileName 
)

Initializes a new instance of the LoggerTask class.

Parameters
folderThe folder.
fileNameName of the file.

Definition at line 31 of file LoggerTask.cs.

32  {
33  fileName = String.IsNullOrWhiteSpace(fileName)
34  ? $"{DateTime.Now.ToFileTime()}_DefaultLog.log"
35  : $"{DateTime.Now.ToFileTime()}_{Path.GetFileName(fileName)}.log";
36  this.streamWriter = new StreamWriter(Path.Combine(folder, fileName));
37  }

Member Function Documentation

void Logging.LoggerTask.DoWork ( )

Does the work. Events to log are filled in a concurrent queue and then read here in serial order.

Definition at line 43 of file LoggerTask.cs.

44  {
45  while (!this.stop)
46  {
47  LoggerInfo logInfo = this.logEntries.Take();
48  if (null != logInfo)
49  this.Log(logInfo);
50  }
51 
52  if (this.streamWriter == null)
53  return;
54 
55  lock (this.lockObject)
56  {
57  this.streamWriter.Close();
58  }
59 
60  this.IsStopped = true;
61  }
bool IsStopped
Gets a value indicating whether this instance is stopped.
Definition: LoggerTask.cs:22

Here is the caller graph for this function:

void Logging.LoggerTask.EnqueueObject ( LoggerInfo  loggerInfo)
package

Enqueues the object.

Parameters
loggerInfoThe logger information.

Definition at line 80 of file LoggerTask.cs.

81  {
82  this.logEntries.Add(loggerInfo);
83  }

Here is the caller graph for this function:

void Logging.LoggerTask.Stop ( )
package

Stops this instance.

Definition at line 88 of file LoggerTask.cs.

89  {
90  this.stop = true;
91  this.logEntries.Add(null);
92  }

Property Documentation

bool Logging.LoggerTask.IsStopped
get

Gets a value indicating whether this instance is stopped.

true if this instance is stopped; otherwise, false.

Definition at line 22 of file LoggerTask.cs.


The documentation for this class was generated from the following file: