Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
day-log-savings
Advanced tools
Day Log Savings is a simple, zero dependencies, Node.js logger that lets you log things in organized, day rotating files.
Day Log Savings is a simple, zero dependencies, Node.js logger that lets you log things in organized, day rotating files.
The name is a play on words of daylight savings, which started when this module was first created.
Each day, a new log file is created, that file is then categorised into month and year folders.
By default, query's are logged like so: [<time>] [<prefix>] <input>
but you can customize this by using the functions options or changing the defaults. Those query's are then written into log files and saved at <project root>/logs/<year>/<month>/<day>.log
. For example: /logs/2020/11/27.log
.
npm install day-log-savings
npm test
Writes an input to the logs, customizable with options.
Function: <logger>.write(<input>, [options]);
Returns: The string which was just logged.
Input {any}: The input which you want to be logged.
Options {object}: {
Prefix {string}: The prefix which appears before the log input, case sensitive. In case of error, prefix is automatically changed to 'ERROR'. Defaults to 'LOG'.
Format {object}: { Change the format of the dates, timestamps and the log message itself. Use %<option>
to define where within the string you want said option to appear.
}
}
logger.write('Input using the default options.');
// [00:00:00] [LOG] Input using the default options.
logger.write('Has a custom prefix.', { prefix: 'cUsToM' });
// [00:00:00] [cUsToM] Has a custom prefix.
logger.write('Custom date, time and message format.', { format: { message: '[%date %time] [%prefix]: %message', date: '%day/%month/%year', time: '%hour.%minute.%second' } });
// [27/11/2020 00.00.00] [LOG]: Custom date, time and message format.
logger.write('Max first line input length reached.', { length: 1 });
// [00:00:00] [LOG]
// Max first line input length reached.
logger.write("This will be logged in the console and log file.", { console: true });
// Console & Log File:
// [00:00] [LOG] This will be logged in the console and log file.
logger.write(new Error('This error will not be stacked.'), { stack: false });
// [00:00:00] [ERROR] This error will not be stacked.
logger.write({ thisObjectWill: 'not be stringified' }, { stringify: false });
// [00:00:00] [LOG] [object Object]
Reads and outputs the last x number lines from the bottom of a log file.
Function: <logger>.read([options]);
Returns: The last x number of lines of a log file.
Options {object}: {
}
logger.read();
// Returns a string containing the last 15 lines of todays log file.
logger.read({ path: '2020/11/27', lines: 5 });
// Returns a string containing the last 5 lines of the 27th of November 2020 log file.
logger.read({ array: true, blanks: false });
// Returns an array containing the last 15 lines of todays log file with all the blank lines removed.
Deletes a log file.
Function: <logger>.remove([path]);
Returns: The path, formatted as 'year/month/day', to the file that was just deleted.
Path {string}: The path, formatted as 'year/month/day', to the log file which you want to delete. Defaults to to todays date.
logger.remove();
// Deletes todays log file.
logger.remove('2020/11/27');
// Deletes the 27th of November 2020 log file.
Change the defaults for one of the functions that the module has.
Function: <logger>.defaults(<method>, [options]);
Returns: The new defaults object of the chosen function.
Method {string}: The name of the function you want to change the defaults for. Example: 'write', 'read'.
Options {object}: The new defaults which you want to set.
logger.defaults('write', { prefix: 'INFO', format: '%date %time %prefix: %message' });
// Changes the default prefix to 'INFO' and the format to '%date %time %prefix: %message'.
logger.defaults('read', { array: true, blanks: false });
// Ensures that the read function returns an array and removes all the blank lines.
logger.defaults('root', { path: `${process.cwd()}/achieve/logs` });
// Changes the default log root from '<project root>/logs' to '<project root>/achieve/logs'.
1.0.3 & 1.0.4 2021/02/16
FAQs
Day Log Savings is a simple, zero dependencies, Node.js logger that lets you log things in organized, day rotating files.
The npm package day-log-savings receives a total of 25 weekly downloads. As such, day-log-savings popularity was classified as not popular.
We found that day-log-savings demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.