Skip to content

Commit 123134d

Browse files
authored
Merge pull request #681 from devforth/feature/AdminForth/1752/i-need-to-be-able-to-configure
fix: add custom config loger support
2 parents 71d91cb + da31100 commit 123134d

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

adminforth/documentation/docs/tutorial/08-UsageOfLogger.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ DB_DEBUG_LEVEL=trace pnpm start
5858

5959
And the logs will be visible as well.
6060

61+
## Single-line logs
6162

63+
By default, log records that contain additional data objects are printed across multiple lines (pretty-printed).
64+
If you prefer each log record to be printed on a single line (for example, to make logs easier to grep or to fit
65+
log collectors), set the `AF_LOG_SINGLE_LINE` environment variable:
6266

67+
```bash
68+
AF_LOG_SINGLE_LINE=true pnpm start
69+
```
6370

71+
Accepted truthy values are `true` and `1`. When unset, logs use the default multi-line pretty format.
6472

adminforth/modules/logger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const baseLogger = pino({
66
options: {
77
colorize: true,
88
ignore: 'pid,hostname',
9+
singleLine: process.env.AF_LOG_SINGLE_LINE === 'true' || process.env.AF_LOG_SINGLE_LINE === '1',
910
}
1011
},
1112
});

0 commit comments

Comments
 (0)