Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
A extremely (but powerful) simple logging system for NodeJS and browser.
npm install acho
If you want to use in the browser (powered by Browserify):
bower install acho --save
and later link in your HTML:
<script src="bower_components/acho/dist/acho.js"></script>
For use it, basically you need to create a new logger instance.
var Acho = require('acho');
var acho = new Acho({color: true});
It's time to use it!
acho.info('hello world');
// => 'hello world'
All public methods for use the library are chaineables:
acho
.info('hello world')
.error('something bad happens');
// => 'info: hello world'
// => 'error: 'something bard happens'
Maybe you don't want output the message, but store it and for later use it can be a good idea:
acho.push('success', 'good job!');
console.log(acho.messages.success);
// => ['good job']
If you want to print later, just call the method print
:
acho.print()
// => 'success: good job!'
At this moment maybe you are thinking: Can I combine print the message with store the message? Absolutely!
acho.add('info', 'this message is printed and stored');
// => 'info: 'this message is printed and stored'
console.log(acho.messages.info)
// => ['this message is printed and stored']
You also can redefine the print method, not exist limits!
acho.print = function() {
// You are in the acho scope, so you can use the properties
// of the object. Check the API documentation.
console.log();
var _this = this;
Object.keys(this.types).forEach(function(type) {
// if (isSuccessOrInfoMessage(type)) console.log();
_this.messages[type].forEach(function(message) {
_this.printLine(type, message);
});
});
};
Do whatever you need for adapt the library of yours requisites: changes colors, add more types, sort the priorities... the internal structure of the object is public and you can edit dynamically. You have the power.
Stablishing the level of your logs is a good way to avoid some information that maybe you don't want to output. The error levels are:
error
: Display calls to .error() messages
.warning
: Display calls from .error()
, .warning() messages
.success
: Display calls from .error()
, .warning(),
success() messages
.info
: Display calls from .error()
, .warning(),
success(),
info() messages
.verbose
: Display calls from .error()
, .warning(),
success()
info(),
verbose() messages
.debug
: Display calls from .error()
, .warning(),
success()
info(),
verbose()
debug() messages
.silly
: Display calls from .error()
, .warning(),
success()
info(),
verbose()
debug()
silly() messages
silent
: Avoid all.The default log level is info
. You can do it in the the constructor:
var acho = new Acho({level: 'silly'})
or in any time:
acho.level = 'debug';
By default the messages structure is minimal: Just the message type followed by the content of the message.
But you can easily customize it, for example, adding an timestamp for each message.
For do it, we offer two methods, outputType
and outputMessage
:
acho = new Acho({
color: true,
level: 'silly',
outputType: function(type) {
return '[' + type + '] »';
},
outputMessage: function(message) {
return Date() + ' :: ' + message;
}
});
Now is moment to your awesome output:
acho.info('I have hungry');
// => '[ info ] » Fri Mar 13 2015 18:12:48 GMT+0100 (CET) :: I have hungry'
You can change how to output the message in the constructor or in any time.
Create a new logger. The options that you can provide are:
false
by default.info
by default.Store internally a type
message.
Store internally a type
message and also output it.
Output a error
message.
Output a warning
message.
Output a success
message.
Output a info
message.
Output a verbose
message.
Output a debug
message.
Output a silly
message.
Determines if a type of message should be outputted.
Determines is a instance of acho
is outputted with colors.
Combine .isPrintable
and .colorize
for print a line correctly.
Default loop for print the messages that are stored internally. By default uses .printLine
in each message iteration.
MIT © Kiko Beats
FAQs
The Hackable Log
The npm package acho receives a total of 548 weekly downloads. As such, acho popularity was classified as not popular.
We found that acho 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.