npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

advanced-logger

v3.0.6

Published

Advanced logger module extendable with plugins. Works in nodejs and browsers

Downloads

2,117

Readme

advanced-logger

Feature branch build npm version install size

Quality checks Quality Gate Status Bugs Code Smells Coverage Duplicated Lines (%) Lines of Code Maintainability Rating Reliability Rating Security Rating Technical Debt Vulnerabilities

Conventional Commits

FOSSA Status

What is it?

It is an extendable isomorphic log sending library written in TypeScript for javascript application in nodejs and browsers.

It can be extended with custom strategy ("when to send logs") and service ("where to send logs").

It does not restrict you with conventions, for example, existence of "logSeverity", "ErrorId" or "message" fields in log.

It supports any format of logs via custom serializer.

Features

  • :scream_cat: It works in browsers and nodejs
  • :articulated_lorry: It is able to send single logs and bundles of them to an external logger
  • It supports different log sending strategies:
    1. :alarm_clock: interval (for example, every 10 seconds)
    2. :loudspeaker: on request (only when you ask)
    3. :alarm_clock: :heavy_plus_sign: :loudspeaker: mixed ("interval" + "on request") (will be done soon)
    4. :steam_locomotive: :railway_car: :railway_car: :railway_car: on bundle size (for example, sends bundles of 100 logs)
    5. :toilet: instant (received 1 log -> sent 1 log)
  • :busts_in_silhouette: It is able to group duplicated logs in certain time interval (for rapid fire of the same logs)
  • :octopus: It is not afraid of circular links in log objects
  • :building_construction: It supports custom format for logs (custom serializer)
  • :dart: It supports different remote logger endpoints (SumoLogic, Loggly and Elasticsearch). Who is the next? ᕙ(ಠ.ಠ)ᕗ

Runtime environment support :running_woman:

Builds are generated as ES2015 bundles for nodejs and browser environments.

:robot: NodeJS - tested on latest lts

:globe_with_meridians: Browser - all latest browsers, that support ES2015 JS.

Documentation

Complete documentation and examples can be found here:

Advanced Logger's Homepage

NPM package link

Simplest usage

Now, the boring part :nerd_face:

Installation

Axios is a required peer dependency. It means that axios is not bundled into logger package, but required to be installed.

As a dependency in a npm project:

npm i --save advanced-logger axios
import {AdvancedLogger, service, strategy} from 'advanced-logger';
// or
const {AdvancedLogger, service, strategy} = require('advanced-logger');

As script tags with CDN:

<!--minified-->
<script src="https://cdn.jsdelivr.net/npm/axios@latest/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/advanced-logger@latest/dist/browser/advanced-logger.browser.min.js"></script>
<!--dev version-->
<script src="https://cdn.jsdelivr.net/npm/axios@latest/dist/axios.js"></script>
<script src="https://cdn.jsdelivr.net/npm/advanced-logger@latest/dist/browser-debug/advanced-logger.browser.js"></script>

Configuration

Lets initiate a logger that sends all logs instantly to Sumologic service.

import {AdvancedLogger, service, strategy} from 'advanced-logger';

const defaultLogConfig = {
    UserAgent: window.userAgent,
    Channel: "my-company",
    BuildVersion: 123,
    Platform: "browser",
    Severity: "DEBUG",
    Data: "",
    Timestamp: "",
    Message: "",
    Category: ""
};

const serviceConfig = {
    url: "https://www.google.nl",
    sourceName: "advancedLoggerTest",
    host: "advanced-logger",
    sourceCategory: "MY/SUMO/namespace",
    method: "POST"
};

const config = {serviceConfig, defaultLogConfig};

const logger = new AdvancedLogger({
    service: new service.SumologicService(config),
    strategy: new strategy.InstantStrategy()
});

logger.log({test: "instant log u1"}); // sends log message :rocket:
logger.log({test: "instant log u2"}); // sends log message :rocket:
logger.log({test: "instant log u3"}); // sends log message :rocket:

Upgrading between breaking changes

2.x to 3.x

  • Install axios to your project or just keep using it if it is already installed
  • Logger is compiled to ES2015 JS target. If your project requires support of old browsers and nodejs, please, make sure that you transpile and add necessary pollyfills to the build