@pexxi/winston-azure-functions
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

winston-azure-functions

Build Status Dependencies Status

This is a fork of https://github.com/upcompass/winston-azure-functions with TypeScript build errors fixed.

Basically, this transport pipes all output to Azure Functions' context.log().

How to use

Setup

Install with npm:

npm install --save @pexxi/winston-azure-functions

or with Yarn:

yarn add @pexxi/winston-azure-functions

Usage

Create a logger component, where you can configure Winston:

import { Context } from "@azure/functions";
import { AzureFunctions } from "winston-azure-functions";
import winston = require("winston");

export const configure = (context: Context) => {
  winston.configure({
    transports: [new AzureFunctions({ context })],
  });
};

export default winston;

In your function, call configure first passing function context as parameter:

import { Context } from '@azure/functions'
import logger, { configureLogger } from "../src/utils/logger";
...
module.exports = function(context: Context) {
  configureLogger(context)
  // rest of the function code...
  logger.info("Logging some stuff...")
};

Now you can use it in the rest of your code, e.g.:

import logger from "./logger"

...

logger.info("Logging on info level...")

Just remember to configure your logger in each function before using it anywhere else during the execution.

Supported log levels

Log level Description
error Writes to error level logging, or lower.
warn Writes to warning level logging, or lower.
info Writes to info level logging, or lower.
verbose Writes to verbose level logging.

Package Sidebar

Install

npm i @pexxi/winston-azure-functions

Weekly Downloads

54

Version

0.1.0

License

MIT

Unpacked Size

14 kB

Total Files

17

Last publish

Collaborators

  • pexxi