# Logger

Logging. Even if ```console.log``` usually seems to be the easiest choice,
we sometimes need have a more robust solution.
Under the hood we are using [Winston](https://github.com/winstonjs/winston) for logging.

## Usage

You can use the already instanstiated one from the registry.

**Getting from the registry** (available in every module)

```javascript
const registry = require('core/server/registry');
const logger = registry.get('logger');

logger.info('Foo Bar module loaded.');
```

## Available methods
```javascript
logger.debug('...');
logger.info('...');
logger.warning('...');
logger.error('...');
```

## Setting the loglevel
The loglevel can be set anywhere in the application.

```javascript
logger.setLevel('debug');
logger.setLevel('info');
logger.setLevel('warning');
logger.setLevel('error');
```

## Passing context and additional arguments
All arguments passed to the log methods will be added to the log message.

```javascript
logger.info('Foo Bar', user, request);
```

## Chainable if
Sometimes it is more easier to read if the condition is chained. If the condition is falsy, then
no log will be created.

```javascript
logger.if(shouldLog()).info('Lorem ipsum dolor sit amet');
```

