
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Yet another Node.js logging module. This is a lightweight, opinionated logging library, which is optimized for async/await (ES7) logging with as little boilerplate code as possible.
Yet another Node.js logging module. This is a lightweight, opinionated logging library, which is optimized for async/await (ES7) logging with as little boilerplate code as possible.
This library only supports error logging (at least for now).
NAME
environment variable to the name of your project (e.g. Awesome Project
). It will be used to group the logs.init()
static method (that file should be in the root of your project)const Log = require('redis-log');
Log.init(__dirname); //this should only be called once
const Log = require('redis-log');
const logger = Log.getLogger(__filename);
async function exampleWithoutLogger(){
const connection = await pg.connect();
const { rows } = await connection.query('SELECT * FROM mytable WHERE id = $1 AND name = $2', [3, 'Test']);
await connection.release();
}
async function exampleWithLogger(){
const connection = await pg.connect();
//in case of an exception, this method will still throw the original one, so you should probably still use try/catch
//the difference is that it will also intercept and log the error to the Redis database
const { rows } = await logger.try(connection.query, ['SELECT * FROM mytable WHERE id = $1 AND name = $2', [3, 'Test']]);
await connection.release();
}
{
"timestamp": "18/04/2019 11:27",
"message": "Failed to execute A(). Stack:",
"stack": "TypeError: Cannot read property 'u' of null\n at A (/Users/patrickpissurno/Documents/GitHub/redis-log/example.js:9:11)\n at B (/Users/patrickpissurno/Documents/GitHub/redis-log/example.js:14:23)\n at main (/Users/patrickpissurno/Documents/GitHub/redis-log/example.js:19:26)\n at Object.<anonymous> (/Users/patrickpissurno/Documents/GitHub/redis-log/example.js:23:1)\n at Module._compile (internal/modules/cjs/loader.js:689:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)",
"arguments": []
}
/*
TypeError: Cannot read property 'u' of null
at A (/Users/patrickpissurno/Documents/GitHub/redis-log/example.js:9:11)
at B (/Users/patrickpissurno/Documents/GitHub/redis-log/example.js:14:23)
at main (/Users/patrickpissurno/Documents/GitHub/redis-log/example.js:19:26)
at Object.<anonymous> (/Users/patrickpissurno/Documents/GitHub/redis-log/example.js:23:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
*/
This is how some production code might look like
const pg = require('./databases').pg; //not required, just for example's sake
const Log = require('redis-log');
const logger = Log.init(__dirname).getLogger(__filename); //init should only be called once
async function doSomeAsyncWork(){
const connection = await pg.connect();
try {
const { rows } = await connection.query('SELECT * FROM mytable WHERE id = $1 AND name = $2', [3, 'Test']);
console.log(rows);
}
catch(ex){
throw ex;
}
finally {
await connection.release();
}
}
logger.try(doSomeAsyncWork);
dirname
: Required. Should be the content of the resolved path for the root folder of the application (usually __dirname
of the starting point of the app)filename
: Required. Should be the content of the __filename
variable for the current module fileopts
: Optional. This object is passed down to the Redis instance (ioredis), so you can configure things like host, port, and all the other options available at their docsasyncFunction
: Required. A function that returns a Promise
functionArguments
: Optional. An array containing the arguments you want that function to receiveextraMessage
: Optional. A string containing some extra information you want to be stored together with the log, such as some sort of label. For example: "myMethod() #1 crashed"shouldThrow
: Optional. Default: true. Whether the function should re-throw the exception in case the Promise throwsMIT License
Copyright (c) 2019 Patrick Pissurno
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 Node.js logging module. This is a lightweight, opinionated logging library, which is optimized for async/await (ES7) logging with as little boilerplate code as possible.
We found that redis-log 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
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.