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

@mojaloop/logging-bc-public-types-lib

v0.5.4

Published

Mojaloop logging bounded context public types lib

Downloads

1,359

Readme

logging-types-lib

Git Commit Git Releases Npm Version NPM Vulnerabilities CircleCI

Mojaloop Logging Service's Types Lib (and minimal console logger)

This library provides stable logging related types to be used in code that does not require actual implementations of a logger, i.e., code that can use the ILogger interface and expect a concrete implementation to be injected by calling components.

It also provides a minimal ILogger implementation for tests/development purposes only.

Types:

  • LogLevel - This enumeration lists the official log levels for the platform;
  • ILogger - This is the interface that all Logger implementations must implement, it specifies the mandatory level of functionaly between all implementations;
  • LogEntry - This type defines a server side log entry object. Only for advanced usage.
  • ConsoleLogger - This is the simplest possible ILogger implementation, that logs to the nodejs/js console.

How to use in components without depending on concrete logger implementations

In the code that doesn't need to be aware of concrete implementations, usually valuable domain code:

import {ILogger} from "@mojaloop/logging-bc-public-types-lib";

// Notice how this code has no knowledge of any concret logger implementations

class MyDomainThing {
    private _logger: ILogger;

    constructor(logger: ILogger) {
        this._logger = logger;
    }

    doAction():void{
        //... do stuff

        this._logger.log("Did stuff");
    }
}

In the application code that usually calls the domain code:

import { ILogger, LogLevel } from "@mojaloop/logging-bc-public-types-lib";
import { DefaultLogger } from "@mojaloop/logging-bc-client-lib";
import { MyDomainThing } from "../domain/my_domain_class";

const BC_NAME = "your_bounded_context_name";
const APP_NAME = "your_app_name";
const APP_VERSION = "0.0.1";
const LOGLEVEL = LogLevel.TRACE;

const loggerImplementation: ILogger = new DefaultLogger(BC_NAME, APP_NAME, APP_VERSION, LOGLEVEL);

// Now we do the dependency injection part by injecting
// the actual implementation via the constructor

const myThing = new MyDomainThing(loggerImplementation);

myThing.doAction();

How to use the console logger

In the application code that usually calls the domain code:

import { ConsoleLogger, ILogger, LogLevel } from "@mojaloop/logging-bc-public-types-lib";

const logger: ILogger = new ConsoleLogger();

logger.debug("debug message");

See also

For more interesting logger implementations, like the DefaultLogger that logs to the console and to a file, or the KafkaLogger that also sends the logs to the central services, see the @mojaloop/logging-bc-client-lib library here

Install

To install this library use:

yarn add @mojaloop/logging-bc-client-lib

OR

npm install @mojaloop/logging-bc-client-lib