Socket
Book a DemoInstallSign in
Socket

yglogger

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yglogger

Simple library for logging

0.0.6
latest
Source
npmnpm
Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

YGLogger

Simple library for logging

Install

npm install --save yglogger

Logging

import * as yglogger from "yglogger";

const options: yglogger.LoggerOptions = {
  // Presence enables console logging
  console: {},
  // Presence enables file logging
  file: {}
};

var logger = yglogger.createLogger({ name: "myApp", version: "1.0" }, options);

logger.info("This is just for information");
logger.warn("Something went wrong", {
  duration: 21.12,
  correlationId: "abc123"
});

Express middleware

app.use(telemetry.initExpressMiddleware(logger));

Passing custom log properties

Use res.locals.logProperties to expose custom properties to the telemetry middleware.

const telemetryLogProperties = (req: express.Request, res: express.Response, next: express.NextFunction) => {
  res.locals.logProperties = {
    originalUrl: req.originalUrl
  };
  next();
};
const telemetryMiddleware = yglogger.initExpressMiddleware(logger);

app.use(telemetryLogProperties, telemetryMiddleware);

Utility functions

Use getCorrelationId() to maintain persistent correlation ID inside a single request.

const correlationId = getCorrelationId(req);

FAQs

Package last updated on 25 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.