# CardX Logging Library

Thin wrapper around [lambda-log](https://www.npmjs.com/package/lambda-log),
a general-purpose JSON logging utility,
that provides expanded levels (trace, fatal)
and checks the environment for settings

## Installation

``` shell
npm --save install @cardx/logger
```

## Usage

By default this logs to the console.
In a command-line environment this will log to stdout.
In a Lambda function this will write to the Cloudtrail.

### Log by Level

``` javascript
import log from "@cardx/logger"

log.fatal("This is a fatal message");
log.error("This is a error message");
log.warn("This is a warning message");
log.info("This is a info message");
log.debug("This is a debug message");
log.trace("This is a trace message");
```

### Special Log Commands

#### Logging Application Status (both info and debug in one call)

``` javascript
log.status(infoMessage, debugMessage);
```

#### Logging nothing

Does nothing.
Maybe you want to reference a variable to quiet the linter.
Maybe you were logging it and might again but know that commented-out code will be deleted.
Maybe you want to do something strange like provide an implementation for `nothing` (that would be truly bizarre).

``` javascript
log.nothing(message);
```

#### Logging Values (for future quantitative analysis)

``` javascript
log.val(key, value);
log.val({ key: value });
```

#### Logging Variables (for debugging)

``` javascript
log.var(key, value);
log.var(key, value, level);
log.var({ key: value });
log.var({ key: value, level: level });
```

### Arcane Options

#### Silent logger

Does nothing but has all the same function signatures.
Useful if you only want to log in certain runtime contexts
but still want the logger functions in your code.

``` javascript
import { silent } from "@cardx/logger"

silent.trace("Hello, world");
```

## Environment Settings

### process.env.LOG\_LEVEL

Suppresses all messages below the set level.
E.g., setting the level to "error" only logs error and critical.

* all
* fatal
* error
* warn
* info (default)
* debug
* trace
* none

### process.env.LOG\_PRETTY\_PRINT

Whether to format JSON strings when logging.

* true
* false (default)

## More Information

* [lambda-log](https://www.npmjs.com/package/lambda-log) on NPM includes more documentation on meta data, tags, and other features
* [Log Levels](https://cardx.atlassian.net/wiki/spaces/dev/pages/31621170/Log+Levels) on the CardX Dev Confluence for a descirption of log levels

## Changelog

1.3.0: Adds `silent` export, `nothing()` function

## License

© CardX. All rights reserved.
