Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rxtoolkit/logs

🗒️ RxJS utilities for backend logging
https://github.com/rxtoolkit/logs

fp functional-programming logging observables package reactive-programming rxjs

Last synced: 7 days ago
JSON representation

🗒️ RxJS utilities for backend logging

Awesome Lists containing this project

README

        

# @rxtk/logs

## Getting started

```bash
npm i @rxtk/logs
```

```bash
yarn add @rxtk/logs
```

## API

### logger
```javascript
import logger from '@rxtk/logs';

// Log info
const data = {foo: 'bar'};
logger.info('an info message', data);
logger.debug('a debug message', data);

// Log an error
const err = new Error('ruh roh');
logger.error(err.message, {stack: err.stack, ...data});
```

### toLog
```javascript
import {of} from 'rxjs';
import logger from '@rxtk/logs';

const input$ = of(...[{data: 'foo'}, {data:'bar'}]);
input$.pipe(logger.toLog('somelabel'));
input$.subscribe(); // will log the values of each item emitted with the provided label
```

### trace
```javascript
import {throwError} from 'rxjs';
import logger from '@rxtk/logs';

const err = new Error('zoinks!');
const input$ = throwError(err);
input$.pipe(logger.trace());
input$.subscribe(); // will log any errors emitted including their stack trace
```