Skip to content

Commit

Permalink
feat: add signale support (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
theogravity committed May 6, 2024
1 parent 2dfe830 commit e6323b7
Show file tree
Hide file tree
Showing 8 changed files with 577 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .changeset/nice-cheetahs-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"loglayer": minor
---

Add [`signale`](https://github.com/klaudiosinani/signale) support

See README.md for more details.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/)

Standardize the way you write logs with the `loglayer` abstraction using your existing logging library
(`bunyan` / `winston` / `pino` / `roarr` / `log4js-node` / `electron-log` / etc).
(`bunyan` / `winston` / `pino` / `roarr` / `log4js-node` / `electron-log` / `signale` / etc).

Spend less time from having to *define* your logs and spend more writing them.

Expand Down Expand Up @@ -60,6 +60,7 @@ logLayer
- [`roarr`](#roarr)
- [`electron-log`](#electron-log)
- [`log4js-node`](#log4js-node)
- [`signale`](#signale)
- [Example integration](#example-integration)
- [API](#api)
- [Constructor](#constructor)
Expand Down Expand Up @@ -264,6 +265,32 @@ const log = new LogLayer({
})
```

### `signale`

[signale docs](https://github.com/klaudiosinani/signale)

- `signale` only works in `node.js` and not the browser
- It is generally used for CLI-based applications as it offers log levels and methods
that would be valuable for CLI output
* `loglayer` does not have integration for the other cli-specific levels (eg: `signale.success()`)
* Use `LogLayer#getLoggerInstance()` to get the `signale` instance to call those levels

```typescript
import { LogLayer, LoggerType } from 'loglayer'
import { Signale } from 'signale'

const log = new LogLayer<Signale>({
logger: {
instance: new Signale(),
type: LoggerType.SIGNALE,
},
})

// if you need to use a signale-specific method
const s = log.getLoggerInstance()
s.success('Operation successful');
```

## Example integration

Using `express` and `pino`:
Expand Down
12 changes: 12 additions & 0 deletions livetests/signale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import signale from "signale";
import { LogLayer, LoggerType } from "../src";
import { testMethods } from "./utils";

const log = new LogLayer({
logger: {
instance: signale,
type: LoggerType.SIGNALE,
},
});

testMethods(log);
Loading

0 comments on commit e6323b7

Please sign in to comment.