Socket
Socket
Sign inDemoInstall

@basd/logger

Package Overview
Dependencies
39
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @basd/logger

@basd/logger is a versatile and robust logging module for Node.js and the browser.


Version published
Maintainers
1
Created

Readme

Source

@basd/logger

the more you know — never forget

npm pipeline license downloads

Gitlab Twitter Discord

@basd/logger is a versatile and robust logging module for Node.js and the browser. It is part of the basd ecosystem of libraries and uses @basd/base for some of its core utilities. It supports logging directly to the console, to files, and to a specified database.

Installation

npm install @basd/logger

Usage

The logger library supports different logging levels (debug, info, warn, error, log) and can print to the console or write to a database.

const Logger = require('@basd/logger')

const myLogger = new Logger()

myLogger.debug('This is a debug message')
myLogger.info('This is an info message')
myLogger.warn('This is a warning message')
myLogger.error('This is an error message')
myLogger.log('This is a generic log message')

Logger Options

You can instantiate the logger with certain options:

const myLogger = new Logger({
  db: myDatabaseInstance, // provide a database instance
  winston: true, // enable winston logging
})

Database Logging

When provided a database instance during instantiation, the logger will write logs to the database:

myLogger.print('debug', 'This is a debug message stored in the DB')

Reading Logs

With the NodeLogger you can read the logs from the filesystem.

const NodeLogger = require('@basd/logger')

const nodeLogger = new NodeLogger()

nodeLogger.list().then(console.log) // list all log files
nodeLogger.read().then(console.log) // read the latest log file
nodeLogger.read('2023-07-24').then(console.log) // read a specific log file by date
nodeLogger.read([new Date('2023-01-01'), new Date()]).then(console.log) // read all logs between two dates

Documentation

Tests

In order to run the test suite, simply clone the repository and install its dependencies:

git clone https://gitlab.com/frenware/core/basd/logger.git
cd basd
npm install

To run the tests:

npm test

Contributing

Thank you! Please see our contributing guidelines for details.

Donations

If you find this project useful and want to help support further development, please send us some coin. We greatly appreciate any and all contributions. Thank you!

Bitcoin (BTC):

1JUb1yNFH6wjGekRUW6Dfgyg4J4h6wKKdF

Monero (XMR):

46uV2fMZT3EWkBrGUgszJCcbqFqEvqrB4bZBJwsbx7yA8e2WBakXzJSUK8aqT4GoqERzbg4oKT2SiPeCgjzVH6VpSQ5y7KQ

License

Logger is MIT licensed.

Keywords

FAQs

Last updated on 24 Oct 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc