@abbit/bunyan-cloud-function 中文文档教程

发布于 3年前 浏览 23 项目主页 更新于 3年前

bunyan-cloud-function

允许您在 Bunyan 的软件包>Google Cloud Functions,让您的日志显示在 StackDriver 上,而不必处理丢失的日志,异步日志保存,由于返回后函数冻结等导致的延迟日志等等。

Install

npm i --save @abbit/bunyan-cloud-function

Usage

import bunyan from 'bunyan';
import {LoggingBunyan} from '@abbit/bunyan-cloud-function';

const loggingBunyan = new LoggingBunyan();

const logger = bunyan.createLogger({
    name: 'test',
    streams: [
        loggingBunyan.stream('INFO') // Will log to stdout in a format that stackdriver understands
    ],
});

Tech stuff

这个包改变了写入标准输出(是的,标准输出)的json格式,以便StackDriver识别消息和日志级别。

我们创建它是因为我们喜欢 Bunyan,而所有其他解决方案都很难使用。 该文件有 100 行长,所以如果它不太适合您,请随意尝试并提交拉取请求。

bunyan-cloud-function

A package that allows you to use Bunyan on Google Cloud Functions, have your logs appear on StackDriver, and not have to deal with missing logs, async log saving, delayed logs due to function freeze after return, etc, etc, etc.

Install

npm i --save @abbit/bunyan-cloud-function

Usage

import bunyan from 'bunyan';
import {LoggingBunyan} from '@abbit/bunyan-cloud-function';

const loggingBunyan = new LoggingBunyan();

const logger = bunyan.createLogger({
    name: 'test',
    streams: [
        loggingBunyan.stream('INFO') // Will log to stdout in a format that stackdriver understands
    ],
});

Tech stuff

This package changes the json format written to stdout(yes, stdout) just enough so that StackDriver recognizes the messages and log levels.

We created this because we like Bunyan and all other solutions were a pain to use. The file is 100 lines long so if it's not quite right for you feel free to play around and submit a pull request.

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文