bellows-logger
v0.1.3
Published
Flexible/Connectable logger library for JavaScript
Downloads
7
Readme
bellows-logger
Flexible/Connectable logger library for JavaScript.
Feature
- Web Audio API like logger
LoggerNode
connect nextLoggerNode
- It is similar with
AudioNode
LoggerNode
transform/deny/filter/attach log data
- It is similar with
Log handling
We have called log data as Chunk.
- Chunk is any data format
- Can implement the transformer as sub class of
LoggerNode
- Can implement output log data to where is
Install
Install with npm:
npm install bellows-logger
Usage
Basic usage of Logger class
import {Logger} from "bellows-logger";
const logger = new Logger();
logger.log("you can log it!");
// logger add the log to queue
logger.start()
// actually start logging
// buffering logs are prune at this timing
logger.log("you can log it!");
// log log log
But, bellows-logger have not default behavior.
You can extensible behavior of logger using LoggerNode
.
This architecture is inspired by Web Audio API.
You can write ConsoleNode
that output to console.log
:
import {LoggerNode} from "bellows-logger";
class ConsoleNode extends LoggerNode {
process(chunk, next) {
// parentNode name
const parentNodeName = this.parentNode.name || "<anonymous>";
console.log(" => " + parentNodeName + " => ", chunk);
// call next node and pass data
next(chunk);
}
}
And use the ConsoleNode
by connect
method:
const logger = new Logger();
// source == input node
const sourceNode = logger.context.createSourceNode();
const consoleNode = new ConsoleNode();
// connect
sourceNode.connect(consoleNode);
// Now, Log actual output to `console`
logger.log("Yay!!!");// show "Yay!!!" in console
Node Tree:
├── root
├── SourceNode
├── ConsoleNode
Changelog
See Releases page.
Running tests
Install devDependencies and Run npm test
:
npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
License
MIT © azu
Credit
Bellows image