dependencies, first working version
This commit is contained in:
58
readme.md
58
readme.md
@@ -1,29 +1,43 @@
|
||||
# logcontext
|
||||
log things contexts in async environments
|
||||
|
||||
## Availabililty
|
||||
[](https://www.npmjs.com/package/logcontext)
|
||||
[](https://GitLab.com/pushrocks/logcontext)
|
||||
[](https://github.com/pushrocks/logcontext)
|
||||
[](https://pushrocks.gitlab.io/logcontext/)
|
||||
the logconext module exposes an easy to use syntax for nodejs style async logcontexts.
|
||||
|
||||
## Status for master
|
||||
[](https://GitLab.com/pushrocks/logcontext/commits/master)
|
||||
[](https://GitLab.com/pushrocks/logcontext/commits/master)
|
||||
[](https://www.npmjs.com/package/logcontext)
|
||||
[](https://david-dm.org/pushrocks/logcontext)
|
||||
[](https://www.bithound.io/github/pushrocks/logcontext/master/dependencies/npm)
|
||||
[](https://www.bithound.io/github/pushrocks/logcontext)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||
[](http://standardjs.com/)
|
||||
```typescript
|
||||
let testLogger = new logcontext.Logger('testNamespace');
|
||||
|
||||
## Usage
|
||||
Use TypeScript for best in class instellisense.
|
||||
testLogger.scope(async () => {
|
||||
testLogger.addData('id1', {
|
||||
someData: 'someValue'
|
||||
});
|
||||
testLogger.log('hi');
|
||||
testLogger.error(new Error('custom error message'));
|
||||
setTimeout(() => {
|
||||
outsideFunction(); // log scope will travel through callbacks and promises
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
For further information read the linked docs at the top of this README.
|
||||
let outsideFunction = () => {
|
||||
sgLogger.log('some message');
|
||||
};
|
||||
```
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||
## class Logger
|
||||
|
||||
[](https://push.rocks)
|
||||
```typescript
|
||||
import { Logger } from 'logcontext';
|
||||
|
||||
// instantiate new Logger
|
||||
// argument optional, if left empty auto generated shortid will be used
|
||||
let myLogger = new Logger('myNamespace');
|
||||
|
||||
// create a scope
|
||||
myLogger.scope(async () => {
|
||||
// everything that is appended to the call stack from inside here will have all appended context data available
|
||||
|
||||
// add some scoped context information
|
||||
myLogger.addData('customerId', '12345678');
|
||||
|
||||
// will log something with priviously appended context of this scope in place
|
||||
myLoger.log('awesomeText');
|
||||
});
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user