You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`maxSeverity` is the logger severity upper limit. All log messages have its own severity and if it is higher than the limit those messages are dropped. Plog defines the following severity levels:
238
+
`maxSeverity` is the logger severity upper limit. Log messages with a severity value higher (less severe) than the limit are dropped.
239
+
240
+
Plog defines the following severity levels:
220
241
221
242
```cpp
222
243
enum Severity
@@ -233,26 +254,70 @@ enum Severity
233
254
234
255
> **Note** Messages with severity level `none` will always be printed.
235
256
236
-
The log format is determined automatically by `fileName` file extension:
237
-
238
-
- .csv => [CSV format](#csvformatter)
239
-
- anything else => [TXT format](#txtformatter)
257
+
Plog provides several convenient initializer functions to simplify logger setup for common use cases. These initializers configure the logger with typical appenders and formatters, so you can get started quickly without manually specifying all template parameters.
240
258
241
-
The rolling behavior is controlled by `maxFileSize` and `maxFiles` parameters:
259
+
### RollingFileInitializer
260
+
Use this when you want to log to a file with automatic rolling (rotation) based on size and count. Add `#include <plog/Initializers/RollingFileInitializer.h>` and call `init`:
242
261
243
-
-`maxFileSize` - the maximum log file size in bytes
Here the logger is initialized to write all messages with up to warning severity to a file in csv format. Maximum log file size is set to 1'000'000 bytes and 5 log files are kept.
255
282
283
+
### ConsoleInitializer
284
+
Use this to log to the console (stdout or stderr) with color output. Add `#include <plog/Initializers/ConsoleInitializer.h>` and call `init`:
- By default it uses [TXT format](#txtformatter) but it can be overriden by specifying a formatter as a template parameter, e.g. `plog::init<plog::CsvFormatter>(...)`.
291
+
- `outputStream` chooses the output stream: `plog::streamStdOut` or `plog::streamStdErr`.
292
+
293
+
Example:
294
+
295
+
```cpp
296
+
#include <plog/Log.h>
297
+
#include <plog/Initializers/ConsoleInitializer.h>
298
+
299
+
plog::init<plog::TxtFormatter>(plog::error, plog::streamStdErr); // logs error and above to stderr
300
+
```
301
+
302
+
### Manual initialization (Init.h)
303
+
For advanced or custom setups add `#include <plog/Init.h>` and call `init`:
0 commit comments