Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
A little Node.js module which improves the behavior of the logging methods of the
console
object without changing its API. Just drop it in.
http://esa-matti.suuronen.org/blog/2012/09/30/improving-console-dot-log-for-node-dot-js/
Improvements affect only log
, info
, warn
and error
methods.
npm install clim
Object newconsole = clim( [String prefix], [Object parent], [Boolean/Object patch parent] )
All parameters are optional.
Just shadow the original console
object and use it like always:
var console = require("clim")();
console.log("message");
console.info("message");
console.warn("message");
console.error("message");
Or if you want process wide improved console object you can monkeypatch the
original object by passing it and true
to clim
:
require("clim")(console, true);
console.log("message");
Or if you don't want to use the util.format
and just pass the arguments to
clim.logWrite
, you can use noFormat
option to do that:
var console = require("clim")("", {}, {
noFormat: true,
patch: false
});
console.log("message")
Add prefix to your log messages by passing it as the first argument:
var console = require("clim")("myapp");
console.log("message");
Sun Sep 30 2012 16:45:57 GMT+0300 (EEST) INFO myapp message
Inherit prefixes from some other console object by passing it as the second parameter:
var clim = require("clim");
var console = clim("myapp");
console.log("message");
function somefunc(){
var logger = clim("somefunc", console);
logger.warn("in function");
}
somefunc();
Sun Sep 30 2012 16:59:12 GMT+0300 (EEST) INFO myapp message
Sun Sep 30 2012 16:59:12 GMT+0300 (EEST) WARNING myapp somefunc in function
Change date format by overriding getTime
:
clim.getTime = function(){
return new Date().toString();
};
Change global log target and formatting details by overriding logWrite
:
clim.logWrite = function(level, prefixes, msg) {
// Default implementation writing to stderr
var line = clim.getTime() + " " + level;
if (prefixes.length > 0) line += " " + prefixes.join(" ");
line += " " + msg;
process.stderr.write(line + "\n");
// or post it web service, save to database etc...
};
FAQs
Console.Log IMproved
The npm package clim receives a total of 1,099 weekly downloads. As such, clim popularity was classified as popular.
We found that clim 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.