Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
A very simple error logger/formatter for Node.
Install as usual with NPM:
npm install --save errorlog
Then configure as the last route of your Express app:
// Get our creator
var errorlog = require('errorlog');
// Create a new logger (with options!)
var log = errorlog(...);
// Foo! Log messages, errors, ...
log('My log message');
The error log can be constructed with the following options:
logger
may be one of the following:
Writable
stream to which error messages will be written to (actually
an object offering a write(...)
function will do).function
that will be invoked once with each message to log.process.stderr
.category
: a category name that will be inserted in the message to log.Options can be specified at construction wrapped in a simple object:
require('errorlog')({
logger: process.stdout,
category: 'my category'
});
Or can be specified as a single parameter (either a Writable
stream, a
function
, or a string
identifying the category):
// Forward errors to Winston's "error" facility
var winston = require('winston');
var errorlog = require('errorlog');
// Pass "winston.error" as a writer function
var log = errorlog(winston.error);
The default Writable
stream or logging function
can be configured
using the defaultLog
property:
var errorlog = require('errorlog');
errorlog.defaultLog = process.stdout;
// All logs will use `process.stdout` unless overridden
var log = errorlog('my category');
The default for this property is process.stderr
, and it will affect all
loggers created after setting it.
Needless to say, logging follow the standard util.format
scheme:
log('I have %d %s, and an object %j', 3, 'apples', { foo: 'bar' });
This will produce an entry like
2015-03-31T13:58:06.601Z - I have 3 apples and an object {"foo":"bar"}
Extra parameters that do not match format characters will be logged in their JSON format, and errors will have their stack traces logged, too. For example:
var extra = { key: 'a simple value' };
var error = new Error('This is an error');
log('I have %d %s', 3, 'apples', extra, error);
Will produce something like
2015-03-30T16:45:01.718Z - I have 3 apples
>>> {"key":"a simple value"}
Error: This is an error
at Error (native)
at ... stacktrace continues ...
For log rotation errorlog
plays nicely with packages like
logrotate-stream
.
Copyright (c) 2015 USRZ.com and Pier Paolo Fumagalli
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Yet another logger for Node
The npm package errorlog receives a total of 87 weekly downloads. As such, errorlog popularity was classified as not popular.
We found that errorlog 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.