Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yellowgate/logger

Package Overview
Dependencies
Maintainers
2
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yellowgate/logger

Simple library for logging

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
2
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 11 Jun 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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc