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

electrode-ui-logger

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electrode-ui-logger

Electrode Logging Utility for UI code

  • 1.1.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
3
Weekly downloads
 
Created
Source

electrode-ui-logger

Log well and prosper. Happy Logging!

This is a logger for UI code with an Electrode server as backend support.

When your UI code is running on the browser, the logger will save up your logs and send them to the log API {basePath}/api/logger every 10 seconds.

When your UI code is running on the server for SSR, the logger will call request.log. This is why the request option is required on the server.

Install

$ npm install electrode-ui-logger --save

Logger usage

The logging interface provides a simple api for generating developer logs.

import logger from "electrode-ui-logger";

logger.log(tags, data, options);

  • tags - array of strings used to specify log level, transport(s) and to otherwise categorize log entries

  • data - string or object, for transmitting log message and other information

  • options - object with additional options. Currently the only option is request which is required for SSR. For CSR the options are ignored and can be considered optional.

Examples:

logger.log(["error"], {err: "some error occurred"}, {request: req});

logger.log("info", {msg: "hello, world"}); // you can use a string for tags directly 

logger.info({msg: "info is hello world"});

Data objects have some special keys:

  • msg: To include a log message along with other data

    logger.log(["info"], { a: "b", msg: "Log message" });

  • err: Errors should be passed in using the err field:

    logger.log(["error"], { err: err });

Reserved keys (do not use as top-level keys in data): tags

Log levels

  • To set the log level, include it in the tags.
  • Valid log levels: "trace", "debug", "info", "warn", "error", "fatal" (case insensitive)
  • If more than one level is specified, the higher level is used. E.g. logger.log(["info", "warn"], {}) will be logged at warn
  • Level defaults to info if none is specified

API Aliases

These are the API aliases for different log levels:

  • logger.info(data, options)
  • logger.warn(data, options)
  • logger.fatal(data, options)
  • logger.error(data, options)
  • logger.debug(data, options)
  • logger.trace(data, options)

FAQs

Package last updated on 05 May 2023

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