Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gruntjs/grunt-legacy-event-logger
Event logger for Grunt legacy libs.
https://github.com/gruntjs/grunt-legacy-event-logger
Last synced: about 2 months ago
JSON representation
Event logger for Grunt legacy libs.
- Host: GitHub
- URL: https://github.com/gruntjs/grunt-legacy-event-logger
- Owner: gruntjs
- License: mit
- Created: 2015-05-27T23:18:58.000Z (over 9 years ago)
- Default Branch: main
- Last Pushed: 2021-03-22T15:20:28.000Z (almost 4 years ago)
- Last Synced: 2024-05-09T19:31:31.379Z (8 months ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 3
- Watchers: 6
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# grunt-legacy-event-logger [![NPM version](https://badge.fury.io/js/grunt-legacy-event-logger.svg)](http://badge.fury.io/js/grunt-legacy-event-logger)
> Event logger for Grunt legacy libs.
## Heads up!
This is not ready for use yet! We'll update the readme when it's ready to go, feel free to star the project if you want updates in the meantime!
## Install
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i grunt-legacy-event-logger --save
```## Usage
```js
var EventLogger = require('grunt-legacy-event-logger');
```## API
### [EventLogger](index.js#L19)
Create an instance of `EventLogger`
### [.base](index.js#L39)
Factory for creating logger emitters.
**Params**
* `name` **{String}**: the name of the log event to emit. Example: `info`
* `message` **{String}**: Message intended to be logged to the console.
* `returns` **{Object}** `EventLogger`: for chaining**Example**
```js
logger.base('info', 'This is an info message');// the above is equivalent to:
logger.create('info');
logger.info('This is an info message')
```### [.create](index.js#L57)
Create a logger method to emit an event with the given `name`.
**Params**
* `name` **{String}**: the name of the log event to emit
* `returns` **{Object}** `EventLogger`: for chaining**Example**
```js
logger.create('info');
logger.on('info', function(msg) {
//=> 'this is an info event!'
});// usage
logger.info('this is an info event!');
```### [.modes](index.js#L75)
Add arbitrary modes to be used for creating namespaces for logger methods.
**Params**
* `modes` **{Array|String}**: Mode or array of modes to add to the logger.
* `returns` **{Object}** `EventLogger`: for chaining**Example**
```js
logger.modes(['verbose', 'notverbose']);
logger.create('info');// usage
logger.verbose.info('emit an info logger event while in "verbose" mode');
logger.notverbose.info('emit an info logger event while in "notverbose" mode');
```### [.operator](index.js#L97)
Add an operator that will invoke the provided getter method.
**Params**
* `ops` **{String}**: List of operations to add to the logger.
* `getter` **{Function}**: Getter method to invoke when the operator property is accessed.
* `returns` **{Object}** `EventLogger`: for chaining**Example**
```js
logger.operator('or', function () {
if (this.mode === 'verbose') return this.notverbose;
if (this.mode === 'notverbose') return this.verbose;
return this.always;
});// usage
logger.verbose.write('verbose').or.write('notverbose');
```## Related projects
* [grunt](http://gruntjs.com/): The JavaScript Task Runner
* [grunt-cli](http://gruntjs.com/): The grunt command line interface.## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/gruntjs/grunt-legacy-event-logger/issues/new)
## Release history
**DATE** **VERSION** **CHANGES**
* 2015-05-26 v0.1.0 First commit
## License
Copyright © 2015 The Grunt Team
Released under the MIT license.***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 04, 2015._