# mobx-logger

> Mobx Logger

Latest version **0.7.1** (published 2018-07-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install mobx-logger
pnpm add mobx-logger
yarn add mobx-logger
bun add mobx-logger
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.1 |
| Published | 2018-07-27 |
| First published | 2016-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 233 |
| Author | Benjamin Winterberg |
| Maintainers | winterbe |
| Keywords | mobx, mobx-logger, logger, logging, log, debug, state management |

## Links

- npm: https://www.npmjs.com/package/mobx-logger
- Repository: https://github.com/winterbe/mobx-logger
- Homepage: https://github.com/winterbe/mobx-logger#readme
- Issues: https://github.com/winterbe/mobx-logger/issues
- npm.io page: https://npm.io/package/mobx-logger

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.7.1 (latest) — 2018-07-27
- 0.7.0 — 2018-03-26
- 0.6.0 — 2017-05-22
- 0.5.0 — 2017-03-10
- 0.4.0 — 2017-01-19
- 0.3.1 — 2016-10-06
- 0.3.0 — 2016-09-28
- 0.2.0 — 2016-08-23
- 0.1.0 — 2016-08-23

## README

# MobX Logger

> Always know what is really going on in your MobX application by logging just the right information.

![mobx-logger](https://raw.githubusercontent.com/winterbe/mobx-logger/master/docs/screenshot.png)

---

<p align="center">
<strong>★★★ Like this project? <a href="https://github.com/winterbe/mobx-logger/stargazers">Leave a star</a>, <a href="https://twitter.com/winterbe_">follow on Twitter</a> or <a href="https://www.paypal.me/winterbe">donate</a> to support my work! Thanks. ★★★</strong>
</p>

## Install

NPM: `npm install mobx-logger`
 
CDN: `https://unpkg.com/mobx-logger/mobx-logger.umd.js` 

## Usage

```js
import {enableLogging} from 'mobx-logger';

// optional
const config = {...};

enableLogging(config);
```

> For Mobx 3 support please use Mobx Logger 0.6.0.

## Options

Unlike MobX DevTools you can simply configure which particular information should be logged to the console. Currently Actions, Reactions, Transactions and Computations are supported.

```js
{
    predicate: () => true|false,
    action: true|false,
    reaction: true|false,
    transaction: true|false,
    compute: true|false
}
```

## Logger Config

You can disable logging for actions and computed properties by providing a static `mobxLoggerConfig`. This is useful to keep the console log clean, e.g. when using a large amount of Mobx models which would result in alot of console logs.

Here's an example of how to disable logging for all actions and computed properties for a given class:

```js
class MyModel {
    static mobxLoggerConfig: {
        enabled: false
    };
    
    // ...
}
```

Alternatively you can disable logging for particular class methods:

```js
class MyStore {
    static mobxLoggerConfig: {
        methods: {
            myAction: false
        }
    };
    
    @action myAction() {
        // calls to this method won't be logged
    }
}
```

You can combine the above examples to whitelist certain actions for being logged:

```js
class MyStore {
    static mobxLoggerConfig: {
        enabled: false,
        methods: {
            myAction: true
        }
    };
    
    @action myAction() {
        // only calls to this method are being logged
    }
    
    // other methods won't be logged ...
}
```

> Please keep in mind that at this point `mobxLoggerConfig` is only available for actions (`@action`) and computed properties (`@computed`).

#### ReactNative

For ReactNative development use this predicate to only enable logging in dev mode with JS debugging enabled:

```js
enableLogging({
    predicate: () => __DEV__ && Boolean(window.navigator.userAgent),
    ...
});
```

## License

MIT

---
_Source: https://npm.io/package/mobx-logger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
