Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikesparr/gcf-logger
Reusable logger for Google Cloud Functions and more inspired by https://12factor.net/logs
https://github.com/mikesparr/gcf-logger
12-factor cloud-functions environment-variables logging
Last synced: about 6 hours ago
JSON representation
Reusable logger for Google Cloud Functions and more inspired by https://12factor.net/logs
- Host: GitHub
- URL: https://github.com/mikesparr/gcf-logger
- Owner: mikesparr
- Created: 2018-09-13T20:43:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-29T21:56:22.000Z (about 6 years ago)
- Last Synced: 2024-12-21T19:02:29.676Z (20 days ago)
- Topics: 12-factor, cloud-functions, environment-variables, logging
- Language: TypeScript
- Homepage:
- Size: 153 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GCF Logger
This is a reusable logger for Google Cloud Functions that includes a traceable ID# Installation
```
npm install gcf-logger
yarn add gcf-logger
```# Usage
## Node
``` javascript
const logger = require("gcf-logger");// instantiate: assume ENV var API_KEY exists
const log = new logger.Logger({
name: "my-feature",
level: 2
});// using
log.info(`Something happened`);
```## Typescript
``` typescript
import {ILogger, Logger} from "gcf-logger";// instantiate: with just name
const log: ILogger = new Logger({
name: "my-feature"
});// pass in reference (requestId) for traceability
log.init({requestId: 'http-12345'});// using
log.info(`Something happened`);
```# Output
The output is sent to stdout as a stringified JSON object, making it easier to consume
in document storage for later analysis.```
{
ts: '2018-01-01T08:32:30.858Z',
msg: 'Something happened',
ref: 'http-12345',
type: 'info',
level: 2,
host: 'localhost',
pid: 12345
}
```# Testing
```
npm test
npm run coverage
```# Build (compiles Typescript to JS)
```
npm run build
```