<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

-   [LoggerFactory](#loggerfactory)
    -   [get](#get)
    -   [settings](#settings)
    -   [handler](#handler)
-   [Logger](#logger)
    -   [with](#with)
    -   [trace](#trace)
    -   [debug](#debug)
    -   [info](#info)
    -   [warn](#warn)
    -   [error](#error)
-   [LEVELS](#levels)
-   [NullHandler](#nullhandler)
    -   [setLevel](#setlevel)
-   [MultiHandler](#multihandler)
    -   [addHandler](#addhandler)
-   [BaseHandler](#basehandler)
    -   [setFormat](#setformat)
-   [ConsoleHandler](#consolehandler)
-   [RawConsoleHandler](#rawconsolehandler)
-   [StreamHandler](#streamhandler)
    -   [setShouldFormat](#setshouldformat)
    -   [setStream](#setstream)

## LoggerFactory

[factory.js:26-127](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/factory.js#L26-L127 "Source code on GitHub")

Handler logger and its settings manipulation.
Default factory returned when you call `require("huzzah")`.

**Parameters**

-   `opts` **{handlerConstructor: [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)}?** Options (optional, default `{handlerConstructor:MultiHandler}`)

### get

[factory.js:39-46](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/factory.js#L39-L46 "Source code on GitHub")

Returns logger with given name

**Parameters**

-   `name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of logger

Returns **[Logger](#logger)** 

### settings

[factory.js:114-116](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/factory.js#L114-L116 "Source code on GitHub")

Returns settings for logger with given name

**Parameters**

-   `name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** logger name

Returns **Handler** 

**Meta**

-   **deprecated**: This is deprecated.


### handler

[factory.js:123-126](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/factory.js#L123-L126 "Source code on GitHub")

Returns hander for logger with given name

**Parameters**

-   `name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** logger name

Returns **Handler** 

## Logger

[logger.js:15-138](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/logger.js#L15-L138 "Source code on GitHub")

Produce log records. It could not be created manually,
always use LoggerFactory instance to create loggers.

**Parameters**

-   `onLogCallback` **[function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** factory, holding this logger
-   `name` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** name of this logger
-   `context` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Set of keys, which will be auto-added to each record

### with

[logger.js:55-62](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/logger.js#L55-L62 "Source code on GitHub")

Creates new Logger with the same name, factory but with given context.
Every property and value of context will be added to log record. This
can be usefull for json logging

**Parameters**

-   `context` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** 

Returns **[Logger](#logger)** new logger with given context

### trace

[logger.js:75-77](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/logger.js#L75-L77 "Source code on GitHub")

Create log record with level TRACE. If first argument is string, it is used as message format, like console.log do.
Supported modifiers %s, %d, %j, %%. If you want to output error, it must be one among all arguments and be last.

**Parameters**

-   `args` **...any** Any arguments. Error must be one and last.

**Examples**

```javascript
logger.trace('User entered %s', userInput);

logger.error('Error happen while sending email', err);
```

### debug

[logger.js:90-92](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/logger.js#L90-L92 "Source code on GitHub")

Create log record with level DEBUG. If first argument is string, it is used as message format, like console.log do.
Supported modifiers %s, %d, %j, %%. If you want to output error, it must be one among all arguments and be last.

**Parameters**

-   `args` **...any** Any arguments. Error must be one and last.

**Examples**

```javascript
logger.trace('User entered %s', userInput);

logger.error('Error happen while sending email', err);
```

### info

[logger.js:105-107](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/logger.js#L105-L107 "Source code on GitHub")

Create log record with level INFO. If first argument is string, it is used as message format, like console.log do.
Supported modifiers %s, %d, %j, %%. If you want to output error, it must be one among all arguments and be last.

**Parameters**

-   `args` **...any** Any arguments. Error must be one and last.

**Examples**

```javascript
logger.trace('User entered %s', userInput);

logger.error('Error happen while sending email', err);
```

### warn

[logger.js:120-122](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/logger.js#L120-L122 "Source code on GitHub")

Create log record with level WARN. If first argument is string, it is used as message format, like console.log do.
Supported modifiers %s, %d, %j, %%. If you want to output error, it must be one among all arguments and be last.

**Parameters**

-   `args` **...any** Any arguments. Error must be one and last.

**Examples**

```javascript
logger.trace('User entered %s', userInput);

logger.error('Error happen while sending email', err);
```

### error

[logger.js:135-137](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/logger.js#L135-L137 "Source code on GitHub")

Create log record with level ERROR. If first argument is string, it is used as message format, like console.log do.
Supported modifiers %s, %d, %j, %%. If you want to output error, it must be one among all arguments and be last.

**Parameters**

-   `args` **...any** Any arguments. Error must be one and last.

**Examples**

```javascript
logger.trace('User entered %s', userInput);

logger.error('Error happen while sending email', err);
```

## LEVELS

[levels.js:7-15](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/levels.js#L7-L15 "Source code on GitHub")

Log levels. Log levels have a priority.
ALL &lt; TRACE &lt; DEBUG &lt; INFO &lt; WARN &lt; ERROR &lt; OFF

## NullHandler

[handlers.js:13-45](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/handlers.js#L13-L45 "Source code on GitHub")

Basic handler. Does not actually handle anything.
Usefull for extensions and stubs. All implementors must implement \_handle(record)
method. record instance shared among all handlers, do not modify it.

### setLevel

[handlers.js:23-32](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/handlers.js#L23-L32 "Source code on GitHub")

Set max accepted log level for this handler

**Parameters**

-   `level` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** 

Returns **this** 

## MultiHandler

[handlers.js:56-76](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/handlers.js#L56-L76 "Source code on GitHub")

**Extends NullHandler**

Holds settings of one logger.
It is max accepted log level and handlers

### addHandler

[handlers.js:68-75](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/handlers.js#L68-L75 "Source code on GitHub")

Adds handler to logger

**Parameters**

-   `handler` **[NullHandler](#nullhandler)** instance

Returns **this** 

## BaseHandler

[handlers.js:86-144](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/handlers.js#L86-L144 "Source code on GitHub")

**Extends NullHandler**

Used as base class for most handlers
All extensions should implement method `_handle(record)`

### setFormat

[handlers.js:130-143](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/handlers.js#L130-L143 "Source code on GitHub")

Set log record format for this handler.
Default record format is `[%date] %-5level %logger - %message%n%error`

Possible parameters:

-   `%d{FORMAT}` or `%date{FORMAT}` - how to format record timestamp. `{FORMAT}` is optional stftime string, by default it is `%Y/%m/%d %H:%M:%S,%L`
-   `%level` or `%le` or `%p` - output record level name like ERROR or WARN
-   `%logger` or `%lo` or `%c` - output logger name
-   `%%` - output %
-   `%n` - output EOL
-   `%err` or `%error` - output stack trace of passed error
-   `%x` or `%x{field}` - output JSON.stringified value of context field

Also available text decorators (now only colors):

-   `%highlight(text)` - will decorate passed text with record level decorator
-   `%cyan(text)`
-   other colors
-   `%cyan.bold(text)`
-   other bold colors

Example: `%date000 %highlight(%5level) %cyan(%logger) - %message%n%error`

Also it is possible to set it to function. One of possible examples jsonFormat (`require('huzzah/json-format')` ).
It can accept the same serializers bunyan can accept and you will have json output at the end.

**Parameters**

-   `format` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function))** It is either formatted string as described, or function returning string and accepts just one argument log record

**Examples**

```javascript
var f = new LoggerFactory();

var logger = f.get('a.b');

f.settings('a.b')
  .addHandler(new ConsoleHandler().setFormat(jsonFormat({
    timestamp: strftimeCompile('%Y/%m/%d %H:%M:%S,%L000')
  })));
```

Returns **this** 

## ConsoleHandler

[handlers.js:151-160](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/handlers.js#L151-L160 "Source code on GitHub")

**Extends BaseHandler**

Just simple console handler

## RawConsoleHandler

[handlers.js:168-180](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/handlers.js#L168-L180 "Source code on GitHub")

**Extends BaseHandler**

Like ConsoleHandler but output whole record to console. This can be usefull
in browser to see inspections.

## StreamHandler

[handlers.js:187-218](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/handlers.js#L187-L218 "Source code on GitHub")

**Extends BaseHandler**

Allow to pass records to stream

### setShouldFormat

[handlers.js:204-207](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/handlers.js#L204-L207 "Source code on GitHub")

Should we format record before passing to stream? By default it is true

**Parameters**

-   `value` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 

Returns **this** 

### setStream

[handlers.js:214-217](https://github.com/btd/huzzah/blob/c66ff701814debf1de768867cdbc60abdf6cda6f/handlers.js#L214-L217 "Source code on GitHub")

Stream to pass records

**Parameters**

-   `stream` **WritableStream** 

Returns **this** 
