Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
frytg committed Jan 10, 2025
1 parent af3e68a commit dd6cfd2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions logger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,20 @@ The logger accesses and injects several env variables to each log event (envs li
- from `os.hostname()` - fallback
- `serviceName` - the service name (e.g. `my-service`)
- from env `SERVICE_NAME` - set by your deployment
- from env `K_SERVICE` - set by Knative such as Google Cloud Run
- `stage` - the stage (e.g. `dev`)
- from env `STAGE` - set by your deployment
- from env `NODE_ENV` - set by your deployment
- `version` - the version (e.g. `1.0.0`)
- from env `SERVICE_VERSION` - set by your deployment
- from env `npm_package_version` - set by your deployment in `package.json`
- `region` - the region (e.g. `eu-west-1`)
- from env `REGION` - set by your deployment
- from env `AWS_REGION` - set by AWS Lambda
- `runtime` - the runtime (e.g. `nodejs-20.11.0`)
- from `process.versions.bun` - set by Bun
- from `process.versions.deno` - set by Deno
- from `process.env.AWS_EXECUTION_ENV` - set by AWS Lambda
- from env `AWS_EXECUTION_ENV` - set by AWS Lambda
- from `process.version` - fallback (usually Node.js)

Additionally these environment variables are triggering different logging formats:
Expand All @@ -59,7 +62,7 @@ Additionally these environment variables are triggering different logging format
## Log Levels

It is currently pre-configured with the
[syslog log levels](https://github.com/winstonjs/winston?tab=readme-ov-file#logging-levels):
[syslog log levels](https://github.com/winstonjs/winston?tab=readme-ov-file#logging-levels) from most to least severe:

```ts
{
Expand Down
6 changes: 3 additions & 3 deletions logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export const detectProcessVersion = (): string => {
// Add global context to log events
const convertGlobals = format((event) => {
event.host = process.env.K_REVISION || process.env.AWS_LAMBDA_FUNCTION_NAME || hostName
event.serviceName = process.env.SERVICE_NAME || null
event.stage = process.env.STAGE || null
event.version = process.env.npm_package_version
event.serviceName = process.env.SERVICE_NAME || process.env.K_SERVICE || null
event.stage = process.env.STAGE || process.env.NODE_ENV || null
event.version = process.env.SERVICE_VERSION || process.env.npm_package_version
event.region = process.env.REGION || process.env.AWS_REGION || null
event.runtime = detectProcessVersion()
return event
Expand Down

0 comments on commit dd6cfd2

Please sign in to comment.