Socket
Socket
Sign inDemoInstall

node-logs-sqlite

Package Overview
Dependencies
121
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-logs-sqlite

A class to manage logs with sql base


Version published
Weekly downloads
8
Maintainers
1
Created
Weekly downloads
 

Readme

Source

node-logs-sqlite

A class to manage logs

Build status Coverage status Dependency status Dev dependency status Issues Pull requests

Installation

$ npm install node-logs-sqlite

Features

  • all the node-logs features
  • Save logs in sqlite formate, order by date (different files) & time
  • Delete old x days local logs automaticly
  • Read local logs

Doc

node-logs inheritage

-- Interfaces --

interface iLogDate {
  year: string,
  month: string,
  day: string
}

interface iLog {
  date: string,
  time: string,
  type: string,
  message: string
}

-- Constructor --

  • constructor ()

-- Methods --

  • -- Accessors --

  • deleteLogsAfterXDays (deleteLogsAfterXDays: number): this

  • localStorageDatabase (localStorageDatabase: string): this

  • -- Init / Release --

  • init(): Promise< resolve<void> | reject<Error> > create local storage if not exists and delete old logs

  • release(): Promise< resolve<void> | reject<Error> >

  • -- Read logs --

  • getLogs(): Promise< resolve< Array<iLogDate> > | reject<Error> >

  • readLog(year: string|number, month: string|number, day: string|number): Promise< resolve< Array<iLog> > | reject< ReferenceError|TypeError|Error > >

Examples

Native

const Logs = require("node-logs-sqlite");
const logs = new Logs();
// optionnal : configure the logger
logs
  .deleteLogsAfterXDays(2)
  .localStorageDatabase(require("path").join(__dirname, "logs.db"))
  .showInConsole(true);
return logs.init().then(() => {

  return logs.log("this is a message", [ "background" ]);

}).then(() => {

  return logs.getLogs().then((logs) => {
     return logs.readLog(year, month, day);
  }).then((logs) => {
     console.log(logs); return Promise.resolve();
  });

}).then(() => {

  return logs.release();

}).catch((err) => {
   console.log(err);
});

Typescript

import Logs = require("node-logs-sqlite");
const logs = new Logs();

logs.init().then(() => {
   return logs.log("log");
});

Tests

$ npm run-script tests

License

ISC

Keywords

FAQs

Last updated on 02 Jul 2021

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