Gathering detailed insights and metrics for log
Gathering detailed insights and metrics for log
Gathering detailed insights and metrics for log
Gathering detailed insights and metrics for log
npm install log
Typescript
Module System
Min. Node Version
Node Version
NPM Version
89.6
Supply Chain
98.1
Quality
76.3
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
220,059,982
Last Day
142,261
Last Week
1,013,374
Last Month
4,561,653
Last Year
57,251,877
43 Stars
291 Commits
1 Forks
4 Watching
2 Branches
4 Contributors
Latest Version
6.3.2
Package Id
log@6.3.2
Unpacked Size
36.66 kB
Size
12.31 kB
File Count
24
NPM Version
10.8.2
Node Version
20.17.0
Publised On
24 Sept 2024
Cumulative downloads
Total Downloads
Last day
-30.8%
142,261
Compared to previous day
Last week
-8.4%
1,013,374
Compared to previous week
Last month
-6.7%
4,561,653
Compared to previous month
Last year
3.9%
57,251,877
Compared to previous year
Configurable, environment and presentation agnostic, with log levels and namespacing (debug style) support
1// Default logger (writes at 'info' level) 2const log = require("log"); 3 4// Log 'info' level message: 5log.info("some info message %s", "injected string"); 6 7// Get namespaced logger (debug lib style) 8const myLibLog = log.get("my-lib"); 9 10// Log 'info' level message in context of 'my-lib' namespace: 11myLibLog.info("some info message in 'my-lib' namespace context"); 12 13// Namespaces can be further nested 14const myLibFuncLog = log.get("func"); 15 16// Log 'info' level message in context of 'my-lib:func' namespace: 17myLibFuncLog.info("some info message in 'my-lib:func' namespace context"); 18 19// Log 'error' level message in context of 'my-lib:func' namespace: 20myLibFuncLog.error("some error message"); 21 22// log output can be dynamically enabled/disabled during runtime 23const { restore } = myLibFuncLog.error.disable(); 24myLibFuncLog.error("error message not really logged"); 25// Restore previous logs visibiity state 26restore(); 27myLibFuncLog.error("error message to be logged");
e.g. if target is Node.js, then install log-node
, and at the top of main module initialize it
1require("log-node")();
Mirror of applicable syslog levels (in severity order):
debug
- debugging information (hidden by default)info
- a purely informational message (hidden by default)notice
- condition normal, but significantwarning
(also aliased as warn
) - condition warningerror
- condition error - to notify of errors accompanied with recovery mechanism (hence reported as log and not as uncaught exception)Note: critical
, alert
, emergency
are not exposed as seem to not serve a use case in context of JS applications,
such errors should be exposed as typical exceptions
log
doesn't force any specific arguments handling. Still it is recommended to assume printf-like message
format, as all currently available writers are setup to support it. Placeholders support reflects one implemented in Node.js format util
Excerpt from Node.js documentation:
The first argument is a string containing zero or more placeholder tokens. Each placeholder token is replaced with the converted value from the corresponding argument. Supported placeholders are:
%s
- String.%d
- Number (integer or floating point value).%i
- Integer.%f
- Floating point value.%j
- JSON. Replaced with the string '[Circular]' if the argument contains circular references.%o
- Object. A string representation of an object with generic JavaScript object formatting. Similar to util.inspect() with options { showHidden: true, depth: 4, showProxy: true }. This will show the full object including non-enumerable symbols and properties.%O
- Object. A string representation of an object with generic JavaScript object formatting. Similar to util.inspect() without options. This will show the full object not including non-enumerable symbols and properties.%%
- single percent sign ('%'). This does not consume an argument.Note to log writer configuration developers: For cross-env compatibility it is advised to base implementation on sprintf-kit
log
on its own doesn't write anything to the console or any other means (it just emits events to be consumed by preloaded log writers).
To have logs written, the pre-chosen log writer needs to be initialized in the main (starting) module of a process.
log-node
- For typical Node.js processeslog-aws-lambda
- For AWS lambda environmentNote: if some writer is missing, propose a PR
Default visibility depends on the enviroment (see chosen log writer for more information), and in most cases is setup through the following environment variables:
LOG_LEVEL
(defaults to notice
) Lowest log level from which (upwards) all logs will be exposed.
LOG_DEBUG
Eventual list of namespaces to expose at levels below LOG_LEVEL
threshold
List is comma separated as e.g. foo,-foo:bar
(expose all foo
but not foo:bar
).
It follows convention configured within debug. To ease eventual migration from debug, configuration fallbacks to DEBUG
env var if LOG_DEBUG
is not present.
When following env var is set writers are recommended to expose timestamps aside each log message
LOG_TIME
rel
(default) - Logs time elapsed since logger initializationabs
- Logs absolute time in ISO 8601 format$ npm test
Project cross-browser compatibility supported by:
To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
17 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More