mirror of
https://github.com/Stone-Red-Code/Stone_Red-C-Sharp-Utilities.git
synced 2026-09-09 18:05:59 +02:00
Created Logging (markdown)
+52
@@ -0,0 +1,52 @@
|
|||||||
|
### Stone_Red_Utilities.Logging
|
||||||
|
|
||||||
|
#### Constructor
|
||||||
|
|
||||||
|
* Logger
|
||||||
|
* Description: Initializes the logger with the default format and a file path.
|
||||||
|
* Parameters: `LogTarget logTarg`, `string file`, `string defaultFormat`
|
||||||
|
* Example usage:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
Logger logger = new Logger(LogTarget.ConsoleAndFile, "events.log", "{<dateTime>:HH:mm:ss} | {<level>,-7} | {<source>,-15} | {<message>}");
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Methods
|
||||||
|
|
||||||
|
* Log
|
||||||
|
* Description: Log the message to the specified output
|
||||||
|
* Parameters: `string message`, `string source`, `LogSeverity logSeverity`
|
||||||
|
* Example usage:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
logger.Log("something happend", "Update manager", LogSeverity.Error);
|
||||||
|
```
|
||||||
|
|
||||||
|
* Output (Depends on the specified log format):
|
||||||
|
|
||||||
|
```text
|
||||||
|
19:15:14 | Error | Update manager | something happend
|
||||||
|
```
|
||||||
|
|
||||||
|
* LogIf
|
||||||
|
* Description: Log the message to the specified output if the condition is met
|
||||||
|
* Parameters: `bool condition`, `string message`, `string source`, `LogSeverity logSeverity`
|
||||||
|
* Example usage:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
logger.Log(IsValid(),"something is invalid", "Update manager", LogSeverity.Error);
|
||||||
|
```
|
||||||
|
|
||||||
|
* Output (Depends on the specified log format):
|
||||||
|
|
||||||
|
```text
|
||||||
|
:15:14 | Error | Update manager | something happend
|
||||||
|
```
|
||||||
|
|
||||||
|
* ClearLogFile
|
||||||
|
* Description: Clears the log file
|
||||||
|
* Example usage:
|
||||||
|
|
||||||
|
```cs
|
||||||
|
logger.ClearLogFile();
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user