New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

spdlog4ts

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spdlog4ts

Spdlog bindings for Node.js with built-in TypeScript declarations

latest
Source
npmnpm
Version
0.2.3
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

spdlog4ts is a spdlog binding for Node.js with built-in TypeScript declarations

  • install

    c++ environment is required, c++11 at least
    npm install spdlog4ts
  • example (TypeScript)

import {
    BasicLogger,
    StdoutLogger,
    AsyncLogger,
    RotatingLogger,
    DailyLogger,
    HourlyLogger,
    EType,
    ELevel
} from 'spdlog4ts';

// use the default logger (stdout, multi-threaded, colored)
BasicLogger.level = ELevel.TRACE;
BasicLogger.critical("critical log");
BasicLogger.error("error log");
BasicLogger.warn("warning log");
BasicLogger.info("info log");
BasicLogger.pattern = "*** [%H:%M:%S %z] [thread %t] %v ***";
BasicLogger.debug("debug log");
BasicLogger.trace("trace log");

BasicLogger.info(EType.DAILY, EType.HOURLY);

// force all loggers flush to disk every 3 seconds
BasicLogger.flushEvery(3);

// create a stdout logger 
const stdlogger = new StdoutLogger('stdout');

// set log pattern
stdlogger.pattern = ">>>>>>>>> %H:%M:%S %z %v <<<<<<<<<";

// set log level
stdlogger.level = ELevel.TRACE;
stdlogger.trace("stdout logger message");

// create an async logger 
const asynclogger = new AsyncLogger('name1', "./logs/async.log");
asynclogger.info("async logger message");

// create a rotating file logger 
const rotatinglogger = new RotatingLogger('name2', "./logs/rotating.log",
    1024 * 1024 * 100/* 100MB */, 50/* at most 50 files */);
rotatinglogger.info("rotating logger message");

// create a daily file logger
const dailylogger = new DailyLogger('name3', './logs/daily.log');
dailylogger.info("daily logger message");

// create an hourly file logger
const hourlylogger = new HourlyLogger('name4', './logs/hourly.log');
hourlylogger.info("hourly logger message");

  • example (JavaScript)

const {
    BasicLogger,
    StdoutLogger,
    AsyncLogger,
    RotatingLogger,
    DailyLogger,
    HourlyLogger,
    EType,
    ELevel
} = require('spdlog4ts');

// use the default logger (stdout, multi-threaded, colored)
BasicLogger.level = ELevel.TRACE;
BasicLogger.critical("critical log");
BasicLogger.error("error log");
BasicLogger.warn("warning log");
BasicLogger.info("info log");
BasicLogger.pattern = "*** [%H:%M:%S %z] [thread %t] %v ***";
BasicLogger.debug("debug log");
BasicLogger.trace("trace log");

BasicLogger.info(EType.DAILY, EType.HOURLY);

// force all loggers flush to disk every 3 seconds
BasicLogger.flushEvery(3);

// create a stdout logger 
const stdlogger = new StdoutLogger('stdout');

// set log pattern
stdlogger.pattern = ">>>>>>>>> %H:%M:%S %z %v <<<<<<<<<";

// set log level
stdlogger.level = ELevel.TRACE;
stdlogger.trace("stdout logger message");

// create an async logger 
const asynclogger = new AsyncLogger('name1', "./logs/async.log");
asynclogger.info("async logger message");

// create a rotating file logger 
const rotatinglogger = new RotatingLogger('name2', "./logs/rotating.log",
    1024 * 1024 * 100/* 100MB */, 50/* at most 50 files */);
rotatinglogger.info("rotating logger message");

// create a daily file logger
const dailylogger = new DailyLogger('name3', './logs/daily.log');
dailylogger.info("daily logger message");

// create an hourly file logger
const hourlylogger = new HourlyLogger('name4', './logs/hourly.log');
hourlylogger.info("hourly logger message");

Keywords

spdlog

FAQs

Package last updated on 07 Jul 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