Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
📝 Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Vlasák committed Oct 23, 2019
1 parent 21dde16 commit 9647528
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ Simple pino-based logger for all your writing needs

## How to use

First step is to create a root logger. Its configuration can be specified on creation and it will be used for all other loggers created.

### Import the logger factory

```js
Expand All @@ -35,15 +33,15 @@ or with import
import loggerFactory from 'cosmas';
```

### Create root logger with default configuration
### Create logger with default configuration

```js
const logger = loggerFactory; // factory itself is a logger
// or
const logger = loggerFactory();
```

### Create root logger with custom configuration
### Create logger with custom configuration

```js
const logger = loggerFactory({
Expand All @@ -52,18 +50,18 @@ const logger = loggerFactory({
});
```

Note: If you want to specify custom configuration it must be done **in the first require** of `cosmas`. Otherwise, default configuration will be used.

See **Options** for a list of possible options.

After you create a root logger, you may use it or you can create a child logger.
### Child loggers
Every logger can be used to create a *child* logger. Child logger inherits all configuration of its *parent* and cannot override them.

Child logger can specify its own *name* which is then concatenated with parent's *name*. Therefore the child logger name is `parentNamechildName`.

```js
const databaseLogger = loggerFactory('database')
const parentLogger = loggerFactory('database', { pretty: false });
const childLogger = parentLogger('.updates');
```

The only difference between root logger and a child logger is that the child logger will print its name in each log message.

## Logger usage

Logger itself is an enhanced and specifically configured `pino` instance, so you may use all basic `pino` log methods
Expand Down

0 comments on commit 9647528

Please sign in to comment.