Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 469b1d7

Browse files
author
Michal Vlasák
committed
📝 Update docs with reserved keys
1 parent 078aa6f commit 469b1d7

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const logger = require('cosmas').default({
133133
If the `NODE_ENV` environment variable is set to `test`, all logs are turned off (minimal loglevel is set to `silent` which effectively turns logging off).
134134

135135
### Pretty print
136-
If you set `pretty` option to `true`, you enable pretty print mode intended for development use. `pkgVersion` and `severity` are ommited from output.
136+
If you set `pretty` option to `true`, you enable pretty print mode intended for development use. `cosmas.pkgVersion`, `cosmas.loggerName` and `severity` are ommited from the output.
137137

138138
### Otherwise
139139
[Standard pino log](https://github.com/pinojs/pino#usage) is used and it's optimized for Google Stackdriver logging. That means that default log level is `debug`, pretty print is turned off and [pino's `messageKey` option](https://github.com/pinojs/pino/blob/master/docs/API.md#pinooptions-stream) is set to `message`.
@@ -159,6 +159,12 @@ Options override both default logger configuration and environment-specific conf
159159
- `req` - logs `body`, `query`, `url`, `method` and omits `password` and `passwordCheck` from `body` and `query`
160160
- `res` - logs `out`, `time`, `headers.x-deviceid`, `headers.authorization` and `headers.user-agent`
161161

162+
## Reserved keys
163+
Cosmas uses some object keys for its own purposes. Those keys should not be used in data you send to log functions as they may be overwritten by Cosmas. Those keys are:
164+
165+
- `cosmas.loggerName` - used for the name of logger
166+
- `cosmas.pkgVersion` - used for the version of `cosmas`
167+
- `message` - used for the log message text
162168

163169
## Tips
164170

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export interface AckeeLoggerFactory extends AckeeLogger {
2525
(data?: string | AckeeLoggerOptions): AckeeLogger;
2626
}
2727

28+
// cannot use Symbols, because they aren't JSON.stringifyable
2829
export const loggerNameKey = 'cosmas.loggerName';
2930
export const pkgVersionKey = 'cosmas.pkgVersion';
3031

0 commit comments

Comments
 (0)