Skip to content

Commit

Permalink
Merge pull request #39 from Olian04/dev
Browse files Browse the repository at this point in the history
4.3.0
  • Loading branch information
Olian04 authored Apr 13, 2020
2 parents 5b76c63 + 169a808 commit a88c2a8
Show file tree
Hide file tree
Showing 21 changed files with 206 additions and 133 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ require('better-logging')(console, {
// By default the text "info" in this stamp, [info], is white, but now it can be any color you want (or that your terminal supports) :)
```

There are also some predefined color themes that you can use if you don't want to write your own.

```js
const { Theme } = betterLogging;
betterLogging(console, {
color: Theme.dark
});

// Theme.dark // default
// Theme.light
// Theme.green
```

Sometimes you might not want all log arguments to be formatted and converted into a string. For these cases you can change the message construction strategy by passing a `MessageConstructionStrategy` enum in the configuration object.

```js
Expand Down Expand Up @@ -251,6 +264,17 @@ betterLogging(better);
better.log('Works!');
```

You can also pass an array of implementation objects.

```js
const customLogging = CustomInstance([
console, // write to stdout & stderr
dbHooks, // store logs in db
]);

customLogging(console);
```

## License

_See [LICENSE](./LICENSE)_
Expand Down
6 changes: 5 additions & 1 deletion demo/javascript.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
require('..')(console);
const betterLogging = require('..');
const { Theme } = betterLogging;
betterLogging(console, {
color: Theme.dark
});

console.logLevel = 4;

Expand Down
6 changes: 4 additions & 2 deletions demo/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import betterLogging from '..';
betterLogging(console);
import betterLogging, { Theme } from '..';
betterLogging(console, {
color: Theme.green,
});

console.logLevel = 4;

Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const betterLogging = require('./dist/api');
module.exports = betterLogging.betterLogging;
module.exports.default = betterLogging.default;
module.exports.Theme = betterLogging.Theme;
module.exports.betterLogging = betterLogging.betterLogging;
module.exports.expressMiddleware = betterLogging.expressMiddleware;
module.exports.MessageConstructionStrategy = betterLogging.MessageConstructionStrategy;
Expand Down
Loading

0 comments on commit a88c2a8

Please sign in to comment.