Represents a logger to a file. More...
Public Member Functions | |
FileLogger (string filename) | |
Constructor. If successful, the file is opened for writing. Raises an exception if the output file cannot be created. | |
void | LogTrace (string msg) |
Log trace messages to the configured output. | |
void | LogInfo (string msg) |
Log informational messages to the configured output. | |
void | LogError (string msg) |
Log error messages to the configured output. | |
Static Public Member Functions | |
static ILogger | CreateFileLogger (string filename) |
Create an instance of a file logger. | |
Private Member Functions | |
void | _WriteLine (string logLevel, string msg) |
Write a formatted line to the log. | |
void ILogger. | LogTrace (string msg) |
Log trace messages to the configured output. | |
void ILogger. | LogInfo (string msg) |
Log informational messages to the configured output. | |
void ILogger. | LogError (string msg) |
Log error messages to the configured output. | |
void IDisposable. | Dispose () |
Close the log file gracefully. | |
Private Attributes | |
StreamWriter | _outputFile |
bool | _disposed |
Represents a logger to a file.
Definition at line 18 of file Bridge_FIleLogger.cs.
|
inline |
Constructor. If successful, the file is opened for writing. Raises an exception if the output file cannot be created.
filename | Name of file to log to. |
UnauthorizedAccessException | "The caller does not have the required permission.", "path specified a file that is read-only.", or "path specified a file that is hidden." |
ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters. |
ArgumentNullException | path is null. |
PathTooLongException | The specified path, file name, or both exceed the system-defined maximum length. |
DirectoryNotFoundException | The specified path is invalid (for example, it is on an unmapped drive). |
NotSupportedException | path is in an invalid format. |
Definition at line 40 of file Bridge_FIleLogger.cs.
References FileLogger._outputFile, and DesignPatternExamples_csharp.File.
|
inlineprivate |
Write a formatted line to the log.
logLevel | The level of the log detail. |
msg | The message to log. |
Definition at line 51 of file Bridge_FIleLogger.cs.
References FileLogger._outputFile, and LoggerHelpers.FormatLogLine().
Referenced by ConsoleLogger.LogError(), FileLogger.LogError(), ConsoleLogger.LogInfo(), FileLogger.LogInfo(), ConsoleLogger.LogTrace(), and FileLogger.LogTrace().
|
inlinestatic |
Create an instance of a file logger.
filename | The filename to log to. |
Definition at line 98 of file Bridge_FIleLogger.cs.
Referenced by Logger.Logger().
|
inlineprivate |
Close the log file gracefully.
Definition at line 81 of file Bridge_FIleLogger.cs.
References FileLogger._disposed, and FileLogger._outputFile.
|
inlineprivate |
Log error messages to the configured output.
msg | The message to log. |
Implements ILogger.
Definition at line 69 of file Bridge_FIleLogger.cs.
References FileLogger._WriteLine().
|
inlineprivate |
Log informational messages to the configured output.
msg | The message to log. |
Implements ILogger.
Definition at line 64 of file Bridge_FIleLogger.cs.
References FileLogger._WriteLine().
|
inlineprivate |
Log trace messages to the configured output.
msg | The message to log. |
Implements ILogger.
Definition at line 59 of file Bridge_FIleLogger.cs.
References FileLogger._WriteLine().
|
private |
Definition at line 21 of file Bridge_FIleLogger.cs.
Referenced by FileLogger.Dispose().
|
private |
Definition at line 20 of file Bridge_FIleLogger.cs.
Referenced by FileLogger._WriteLine(), FileLogger.Dispose(), and FileLogger.FileLogger().