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
Copy file name to clipboardExpand all lines: logger.md
+5-41Lines changed: 5 additions & 41 deletions
Original file line number
Diff line number
Diff line change
@@ -8,24 +8,12 @@ The logging utility coming with Supercharge is configurable to make it seamless
8
8
9
9
10
10
## Configuraiton
11
-
The configuration file for the logger is located at `config/logging.js` containing the default log driver and channels. You can configure each log channel to your own needs.
11
+
Tba.
12
12
13
-
The default log driver is `console` printing everything to your terminal. When using the `file` driver, you may adjust the log file name which defaults to `app.log` and is located in `storage/logs/app.log`
14
13
14
+
### Available Log Drivers
15
+
Tba.
15
16
16
-
### Available Drivers
17
-
Supercharge uses a driver-based approach for logging. A driver represents a single channel or multiple channels. A channel itself describes the destiation for log messages. Here’s a list of available logging drivers and the related log channels:
18
-
19
-
| Channel Driver | Description |
20
-
|----------------- |------------------- |
21
-
|`stacked`| Logging to all available channels: `console` and `file`|
22
-
|`console`| Logging all messages to the terminal |
23
-
|`file`| Logging all messages to a dedicated log file |
24
-
25
-
26
-
```info
27
-
At this point, you can’t configure the stacked logger to exclude a specific channel. It will log to all available channels. This is very likely to change in future releases.
28
-
```
29
17
30
18
## Using the Logger
31
19
The logging utility is part of the Supercharge framework. It provides methods for seven different log levels:
@@ -44,29 +32,5 @@ Logger.silly(message)
44
32
The logger provides a method corresponding to the supported log levels.
45
33
46
34
47
-
#### Logging Context Data
48
-
Use the logger anywhere in your application. Supercharge ensures to initialize the logger when starting your application. For example, you may log an `info` message in your routes. Add context information like an ID with the help of template strings:
You may also pass context data to the log message using the [`sprintf`](https://en.wikipedia.org/wiki/Printf_format_string) syntax. Both channels, console and file, support the `sprintf` syntax format for all log levels. Here’s an example of a debug message containing the details about incoming request parameters:
69
-
70
-
```js
71
-
Logger.debug(`Showing blog post with params: %j`, request.params)
Logging allows you to provide transparency in your application. If you want to learn more about the processing and details of your application parts, logging is a good way. Supercharge provides a solid logger using the [Winston](https://github.com/winstonjs/winston) logging library.
6
+
7
+
The logging utility coming with Supercharge is configurable to make it seamless for you to log to different destinations, like the console or a log file.
8
+
9
+
10
+
## Configuraiton
11
+
The configuration file for the logger is located at `config/logging.js` containing the default log driver and channels. You can configure each log channel to your own needs.
12
+
13
+
The default log driver is `console` printing everything to your terminal. When using the `file` driver, you may adjust the log file name which defaults to `app.log` and is located in `storage/logs/app.log`
14
+
15
+
16
+
### Available Drivers
17
+
Supercharge uses a driver-based approach for logging. A driver represents a single channel or multiple channels. A channel itself describes the destiation for log messages. Here’s a list of available logging drivers and the related log channels:
18
+
19
+
| Channel Driver | Description |
20
+
|----------------- |------------------- |
21
+
|`stacked`| Logging to all available channels: `console` and `file`|
22
+
|`console`| Logging all messages to the terminal |
23
+
|`file`| Logging all messages to a dedicated log file |
24
+
25
+
26
+
```info
27
+
At this point, you can’t configure the stacked logger to exclude a specific channel. It will log to all available channels. This is very likely to change in future releases.
28
+
```
29
+
30
+
## Using the Logger
31
+
The logging utility is part of the Supercharge framework. It provides methods for seven different log levels:
The logger provides a method corresponding to the supported log levels.
45
+
46
+
47
+
#### Logging Context Data
48
+
Use the logger anywhere in your application. Supercharge ensures to initialize the logger when starting your application. For example, you may log an `info` message in your routes. Add context information like an ID with the help of template strings:
You may also pass context data to the log message using the [`sprintf`](https://en.wikipedia.org/wiki/Printf_format_string) syntax. Both channels, console and file, support the `sprintf` syntax format for all log levels. Here’s an example of a debug message containing the details about incoming request parameters:
69
+
70
+
```js
71
+
Logger.debug(`Showing blog post with params: %j`, request.params)
0 commit comments