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.
An extremely simple (but powerful) logging system for NodeJS and browser.
npm install acho
If you want to use it in the browser (powered by Browserify):
bower install acho --save
and later add it to your HTML:
<script src="bower_components/acho/dist/acho.js"></script>
To use it, you just 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 are chaineables:
acho
.info('hello world')
.error('something bad happens');
// => 'info: hello world'
// => 'error: 'something bard happens'
Maybe you don't want to output the message, but store it for later use:
acho.push('success', 'good job!');
console.log(acho.messages.success);
// => ['good job']
If you want to print previously stored messages, just call the method print
:
acho.print()
// => 'success: good job!'
You might be thinking: Can I combine both, to store and both print a 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 can also modify the print method!
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) {
_this.messages[type].forEach(function(message) {
_this.printLine(type, message);
});
});
};
You can completely customize the library to your requirements: changes colors, add more types, sort the priorities... the internal structure of the object is public and you can edit it dynamically. You have the power.
Establishing the loglevel is a good way to filter out undesired information from output. The available 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 output.The default log level is info
. You can define it in the the constructor:
var acho = new Acho({level: 'silly'})
or at runtime:
acho.level = 'debug';
By default the messages structure is brief: Just the message type followed by the message itself.
But you can easily modify the output. For example, let's add a timestamp to each message.
To customize the output 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;
}
});
This results in your awesome output:
acho.info('I am hungry');
// => '[ info ] » Fri Mar 13 2015 18:12:48 GMT+0100 (CET) :: I am hungry'
You can modify the outputted message at any time.
Create a new logger. Available options:
false
by default.info
by default.Store a message of given type
internally.
Store a message of given type
internally 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
to print a line correctly.
Default loop to print the messages that are stored internally. By default it uses .printLine
in each message iteration.
MIT © Kiko Beats
1.0.2 (2015-03-17)
<a name="1.0.1"></a>
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.