filewriter-siawwad

1.0.6 • Public • Published

Users can import this module into their Node.js scripts and utilize the functions to create new log every hour, ensuring organized and time-stamping logs.

MODULE FEATURES:

Automatically creates a new log file every hour.

Handles data asynchronously.

Provides the flexibility to set a custom log directory.

Incorporates an execution timer to measure the duration of each process.

Usage:

Include it in your project

const fileWriter = require('filewriter-siawwad');

Setting a custom log directory (optional)

fileWriter.setLogDir('your dir path');

Note: the default directory is 'Logs', ensure that the directory is exists and is writable.

logging data

const dataToLog = 'This is a log message.';
fileWriter.logData('data to log');

The 'startTimer' function is responsible for initiating the timer. When called, it records the current timestamp, marking the beginning of the logging process.

fileWriter.startTimer();

the 'endTimer' function is responsible for concluding the timer. When called, it records the current timestamp, marking the end of the logging process. Subsequently, it calculates the duration between the start and end times.

fileWriter.endTimer('your label');

The duration between the start and end times is automatically calculated and logged as part of the 'endTimer' function. This information (plus the timestamp of each operation) is valuable for assessing the efficiency of the logging process.

Package Sidebar

Install

npm i filewriter-siawwad

Weekly Downloads

1

Version

1.0.6

License

ISC

Unpacked Size

4.39 kB

Total Files

3

Last publish

Collaborators

  • sidra-ad