@alt-javascript/logger-darkly

1.0.1 • Public • Published

A Listener For Updating The LoggerCategoryCache From A Launch Darkly Variation

NPM
Language Badge Package Badge
release notes

Introduction

An "Arctor" implementation for listening for and updating the LoggerCategoryCache from a Launch Darkly variation in server-side node.js.

Usage

To use the module, follow the example in the included below file, which plays nicely with all the other @alt-javascript modules.

The Scanner, takes a LoggerCategoryCacheVariation which is injected with the global root context LoggerCategoryCache instance (each logger has a handle to it, though we could get it directly from global.boot.contexts.root.loggercategoryCache) that will act on flagged LaunchDarkly JSON config and replace the internal cache object within it's see(clearly) function.

const LaunchDarkly = require('launchdarkly-node-server-sdk');
const ScannerDarkly = require('@alt-javascript/scanner-darkly');
const {config} = require("@alt-javascript/config");
const {boot} = require("@alt-javascript/boot");
const {LoggerFactory} = require('@alt-javascript/logger');
boot({config});


const LoggerCategoryCacheVariation = require('@alt-javascript/scanner-darkly'); // this  uses booted logging config, so is required after boot().

const logger = LoggerFactory.getLogger('@alt-javascript/scanner-darkly/scan');
const ldlogger = LoggerFactory.getLogger('LaunchDarkly');
const SDK_KEY = config.get('scanner.darkly.sdk-key');
const scannerDarkly = new ScannerDarkly(
    new LoggerCategoryCacheVariation('logging-levels', {"key": "user@test.com"}, {"/":"error"},logger.cache),
    SDK_KEY,
    {logger: ldlogger});

scannerDarkly.init();
// ... later, on process exit.
scannerDarkly.destroy();

/@alt-javascript/logger-darkly/

    Package Sidebar

    Install

    npm i @alt-javascript/logger-darkly

    Weekly Downloads

    9

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    6.01 kB

    Total Files

    7

    Last publish

    Collaborators

    • craigparra