GithubHelp home page GithubHelp logo

simenandre / pino-cloud-logging Goto Github PK

View Code? Open in Web Editor NEW
14.0 2.0 0.0 207 KB

Pino configuration for Google Cloud Platform. Enabled structured logging!

License: Apache License 2.0

JavaScript 11.84% TypeScript 88.16%
google-cloud-platform logging pino typescript

pino-cloud-logging's Introduction

Use Pino with Google Cloud Logging

This package provides a simple configuration to use with Pino to make it adhere to Google Cloud Logging structured logging.

Quickstart

yarn add pino-cloud-logging

When you initialize your Pino logging instance, you'll use our gcpLogOptions.

import Pino from 'pino';
import { gcpLogOptions } from 'pino-cloud-logging';

const logger = Pino(gcpLogOptions());

logger.info('Hello ๐Ÿ‘‹');

You can extend the configuration provided by this package like this:

gcpLogOptions({
  level: 'INFO',
  // Options can be found here:
  // https://github.com/pinojs/pino/blob/master/docs/api.md#options
});

You can also provide some of the default context like this:

gcpLogOptions(
  {
    /* ... */
  },
  { serviceName: 'hello-world', version: '2020-01-01' },
);

If you want to provide insertId (or any other runtime data), you can add those with the mixin function.

gcpLogOptions(
  {
    /* ... */
  },
  { mixin: () => ({ insertId: randomUUID() }) },
);

Or even provide context from OpenTelemetry.

import { context, getSpan } from '@opentelemetry/api';
gcpLogOptions(
  {
    /* ... */
  },
  { mixin: () => getSpan(context.active())?.context() ?? {} },
);

pino-cloud-logging's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pino-cloud-logging's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/workflow.yml
  • actions/checkout v4@3df4ab11eba7bda6032a0b82a6bb43b11571feac
  • google-github-actions/release-please-action v3
  • actions/setup-node v3
npm
package.json
  • pino ^8.0.0
  • @bjerk/eslint-config ^4.0.0
  • @cobraz/prettier ^2.0.0
  • @tsconfig/node16 ^1.0.2
  • @types/jest ^29.0.0
  • @types/node 18
  • jest ^29.0.0
  • prettier ^2.5.1
  • ts-jest ^29.0.0
  • ts-node ^10.4.0
  • typescript ^5.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.