diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d7517c3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +Changelog +========= +### 0.1.0 +Initial release of Winston logger adapter for Space.Logger diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..453637c --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,16 @@ +The MIT License (MIT) +Copyright (c) <2016> + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ddbf609 --- /dev/null +++ b/README.md @@ -0,0 +1,144 @@ +# Space.logging.Winston +**Adds Winston logger() adapter for Space.Logger** + +Wouldn't be nice to be able to use most of current top-notch logging platforms out with just snap of a finger(or few...)? This is where Winston comes in to play. You can use whatever logging _transport_(storage device) you wish that is currently supported by Winston or many additional - done by community. + +Need display something with: + +* console? Use: `winston.transports.Console` + +## Installation +`meteor add space:winston` + +*Compatible with `Meteor 1.2.x - 1.3.x`* + +## Setup + +First, setup your own `Space.Application` or `Space.Module`. Simple example: + +``` +Space.Application.define('MyApp', { + + configuration: { + appId: 'MyApp' + log: { + enabled: true + } + }, + + requiredModules: [ + 'Space.logging.Winston' + ], +}); +``` +And voila! With few lines - you got not only Winston, but also - default `winston.transports.Console` _transport_ configured by default with options like: + +``` +{ + colorize: true, + prettyPrint: true, + level: 'info' +} +``` +The key components out here are: + +#### Configuration: +``` + configuration: { + ... + log: { + enabled: true + } + }, +``` +Adding `log` object with property `enabled: true` enables logging with our `Space.Logger` provided by `space:base` package. + +**Its crucial part, without it - `Space.Logger` no logs shall pass(winky face) through any logs to added libraries(adapters).** + +Now on its own `Space.Logger` behaves just like a simple container without filling it up with additional logging libraries using _adapters_. + +#### Module: +The heavy lifting of setting up Winston and initializing transports is done here with module: +``` + requiredModules: [ + 'Space.logging.Winston' + ], +``` + +## Adding new transports + +####Configuration: +There are two ways of configuring additional transports. First one - when `Space.logging.Winston` module is initialized by passing additional transports to apps `configuration` object like: + +``` +Space.Application.define('MyApp', { + + configuration: { + appId: 'MyApp' + log: { + enabled: true, + winston: { + transports: [ + new winston.transports.Console({ + colorize: true, + prettyPrint: true + level: 'debug' + }) + ] + } + } + } + requiredModules: [ + 'Space.logging.Winston' + ], +}); +``` +On this example default console transport(`winston.transports.Console`) will be replaced with our own instance configured to our needs. + +**Adding any additional transport by `configuration` - will remove default console transport. If you wish to preserve console transport: just add it to `configuration.log.winston.transports` array.** + +####Initialization hooks + +By using `Space.Application` or `Space.Module` `onInitialize` hook like this: + +``` +Space.Application.define('MyApp', { + + configuration: { + appId: 'MyApp' + log: { + enabled: true, + winston: { + transports: [ + new winston.transports.Console({ + colorize: true, + prettyPrint: true + level: 'debug' + }) + ] + } + } + } + requiredModules: [ + 'Space.logging.Winston' + ], + + onInitialize() { + let winstonAdapter = this.injector.get('Space.Logger.WinstonAdapter'); + winstonAdapter.addTransport(winston.transports.Console, { + name: 'yet-another-console-transport', + colorize: false, + prettyPrint: false, + level: 'debug' + }); + }, + +}); +``` + +## Release History +You can find the complete release history in the +[changelog](https://github.com/meteor-space/winston/blob/master/CHANGELOG.md) + +## License +Licensed under the MIT license. \ No newline at end of file