https://github.com/relaycorp/pino-cloud-js
Pino integration for cloud logging services like Google Stackdriver
https://github.com/relaycorp/pino-cloud-js
pino stackdriver
Last synced: 19 days ago
JSON representation
Pino integration for cloud logging services like Google Stackdriver
- Host: GitHub
- URL: https://github.com/relaycorp/pino-cloud-js
- Owner: relaycorp
- License: mit
- Created: 2021-01-28T18:52:23.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-31T00:23:36.000Z (27 days ago)
- Last Synced: 2025-03-31T01:24:02.275Z (27 days ago)
- Topics: pino, stackdriver
- Language: TypeScript
- Homepage: https://docs.relaycorp.tech/pino-cloud-js/
- Size: 1.92 MB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @relaycorp/pino-cloud
This library generates [Pino](https://getpino.io) configuration to format log entries in such a way that they can be properly ingested by cloud logging services such as those on Google Cloud Platform (GCP).
At this point, only GCP's Cloud Logging and Error Reporting services are supported, but we'd welcome any PRs to support additional targets, such as Elastic Search or AWS CloudWatch Logs.
## Install
Releases are automatically pushed to [NPM](https://www.npmjs.com/package/@relaycorp/pino-cloud). For example, to get the latest release, run:
```shell
npm install @relaycorp/pino-cloud
```## Usage
This library simply returns a configuration object for Pino, which you augment before passing to Pino. For example:
```typescript
import { getPinoOptions } from '@relaycorp/pino-cloud';const LOGGER = pino({
...getPinoOptions(process.ENV.LOGGING_TARGET, {
name: 'your-app-name',
version: '1.0.2',
}),
level: 'debug',
});
```If the environment variable `LOGGING_TARGET` is unset, an empty object is returned.
## Targets
### `gcp`
`error` and `fatal` logs are augmented to include Error Reporting fields, like the name and version of your app.
Additionally, if the log contains an `err` field that is an instance of `Error`, its stack trace will be added to the field `stack_trace` -- Where Error Reporting expects to find it.
## API documentation
The API documentation can be found on [docs.relaycorp.tech](https://docs.relaycorp.tech/pino-cloud-js/).
## Contributing
We love contributions! If you haven't contributed to a Relaycorp project before, please take a minute to [read our guidelines](https://github.com/relaycorp/.github/blob/master/CONTRIBUTING.md) first.