bellows-logger

0.1.3 • Public • Published

bellows-logger Build Status

bellows

Flexible/Connectable logger library for JavaScript.

Feature

  • Web Audio API like logger
  • LoggerNode connect next LoggerNode
    • It is similar with AudioNode
    • LoggerNode transform/deny/filter/attach log data

Web Audio API

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.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

Credit

Bellows image

Readme

Keywords

Package Sidebar

Install

npm i bellows-logger

Weekly Downloads

1

Version

0.1.3

License

MIT

Last publish

Collaborators

  • azu