Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Provide logger written in TypeScript for TypeScript or JavaScript.
$ npm install -g typings
$ npm install log-debug
The Logger class can be used to create a simple logger with configurable output streams and can be accessed using either import * as $log from 'log-debug'
or var $log = require('debug-log')
.
import * as $log from "log-debug";
$log.debug('Test').
var $log = require('log-debug');
$log.debug('Test').
stdout: NodeJS.WritableStream
stderr: NodeJS.WritableStream
noColors: boolean
Creates a new Logger
by passing one or two writable stream instances. stdout
is a writable stream to print log or info output. stderr
is used for warning or error output. If stderr
isn't passed, the warning and error output will be sent to the stdout`.
import * as Fs from "fs";
import * as $log from "log-debug";
const output = Fs.createWriteStream('./stdout.log');
const errorOutput = Fs.createWriteStream('./stderr.log');
// custom simple logger
const logger = new $log.Logger(output, errorOutput);
// use it like console
var count = 5;
logger.debug('count: %d', count);
// in stdout.log: count 5
The $log
is a special Logger
whose output is sent to process.stdout
and process.stderr
. It is equivalent to calling:
new $log.Logger(process.stdout, process.stderr);
args: any[]
Prints to stdout with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf() (the arguments are all passed to util.format()).
import * as $log from 'log-debug';
$log.debug('test'); //[DEBUG] test
$log.debug({test:'test'}); //[DEBUG] {'test':'test}
$log.debug('Format %j', {test:'test'}); //[DEBUG] Format {'test':'test}
//With stacktrace
$log.debug('test').withTrace(); //[DEBUG] test
// at Context.<anonymous> (/directory/file.ts:80:10)
// at ...
//With line only
$log.debug('test').withLine(); //[DEBUG] test
// at (/directory/file.ts:80:10)
If formatting elements (e.g. %j) are not found in the first string then util.inspect() is called on each argument and the resulting string values are concatenated. See util.format() for more information.
args: any[]
The Logger.info() function is an alias for Logger.debug().
args: any[]
Prints to stderr the string '[TRACE]', followed by the util.format() formatted message and stack trace to the current position in the code.
$log.trace('Show me');
//[TRACE] Show me
// at Context.<anonymous> (/projects/log-debug/test/spec/log.spec.ts:251:45)
// at callFn (/projects/log-debug/node_modules/mocha/lib/runnable.js:315:21)
// at Test.Runnable.run (/projects/log-debug/node_modules/mocha/lib/runnable.js:308:7)
// at Runner.runTest (/projects/log-debug/node_modules/mocha/lib/runner.js:422:10)
// at /projects/log-debug/node_modules/mocha/lib/runner.js:533:12
// at next (/projects/log-debug/node_modules/mocha/lib/runner.js:342:14)
// at /projects/log-debug/node_modules/mocha/lib/runner.js:352:7
// at next (/projects/log-debug/node_modules/mocha/lib/runner.js:284:14)
// at Immediate._onImmediate (/projects/log-debug/node_modules/mocha/lib/runner.js:320:5)
// at processImmediate [as _immediateCallback] (timers.js:383:17)
args: any[]
Prints to stderr with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf() (the arguments are all passed to util.format()).
import * as $log from 'log-debug';
$log.error('test'); //[ERROR] test
$log.error({test:'test'}); //[ERROR] {'test':'test}
$log.error('Format %j', {test:'test'}); //[ERROR] Format {'test':'test}
//With stacktrace
$log.error('test').withTrace(); //[ERROR] test
// at Context.<anonymous> (/directory/file.ts:80:10)
// at ...
//With line only
$log.error('test').withLine(); //[ERROR] test
// at (/directory/file.ts:80:10)
If formatting elements (e.g. %j) are not found in the first string then util.inspect() is called on each argument and the resulting string values are concatenated. See util.format() for more information.
args: any[]
The Logger.warn() function is an alias for Logger.error().
$ npm install -g mocha
$ npm test
The MIT License (MIT)
Copyright (c) 2016 Romain Lenzotti
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
Provide logger written in TypeScript for TypeScript or JavaScript.
The npm package log-debug receives a total of 5 weekly downloads. As such, log-debug popularity was classified as not popular.
We found that log-debug 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.