# pino-systemd-prefix-transport

> a simple pino transport (v7+) for adding systemd daemon logging prefixes.

Latest version **0.1.1** (published 2022-10-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install pino-systemd-prefix-transport
pnpm add pino-systemd-prefix-transport
yarn add pino-systemd-prefix-transport
bun add pino-systemd-prefix-transport
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2022-10-05 |
| First published | 2022-10-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=16.0.0 |
| Dependencies | 7 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Luke Wu |
| Maintainers | luke516 |
| Keywords | pino, transport, systemd |

## Links

- npm: https://www.npmjs.com/package/pino-systemd-prefix-transport
- Repository: https://github.com/Luke516/pino-systemd-prefix-transport
- Homepage: https://github.com/Luke516/pino-systemd-prefix-transport#readme
- Issues: https://github.com/Luke516/pino-systemd-prefix-transport/issues
- npm.io page: https://npm.io/package/pino-systemd-prefix-transport

## Dependencies (7)

- [nopt](https://npm.io/package/nopt.md) ^5.0.0
- [pump](https://npm.io/package/pump.md) ^3.0.0
- [split2](https://npm.io/package/split2.md) ^3.2.2
- [through2](https://npm.io/package/through2.md) ^4.0.2
- [sonic-boom](https://npm.io/package/sonic-boom.md) ^2.3.0
- [fast-safe-stringify](https://npm.io/package/fast-safe-stringify.md) ^2.0.2
- [pino-abstract-transport](https://npm.io/package/pino-abstract-transport.md) ^0.4.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 0.1.1 (latest) — 2022-10-05
- 0.1.0 — 2022-10-04

## README

# pino-systemd-prefix-transport

*pino-systemd-prefix-transport* is a [transport][transport] for the [pino][pino] logger. *pino-systemd-prefix-transport* receives *pino* logs and adds a 3-character prefix '<' N '>' to the log, where N is a digit from 0 to 7 indicating severity of the log line.By default, Systemd will interpret the prefix as the log level, omit it, and log the rest of the string at the specified level.

This package might be useful if you run your node application as a Systemd service (for example, using the AWS Elastic Beanstalk cloud service), and you want to control the log level being sent to Syslog.

Reference:
[systemd.exec(5)][systemd], 
[sd-daemon(3)][sd-daemon]

[systemd]: https://www.freedesktop.org/software/systemd/man/systemd.exec.html#Logging%20and%20Standard%20Input/Output
[sd-daemon]: https://www.freedesktop.org/software/systemd/man/sd-daemon.html
[transport]: https://getpino.io/#/docs/transports
[pino]: https://www.npmjs.com/package/pino


## Example

Given the log:

```json
{"level":30,"time":1664851979134,"pid":20379,"hostname":"MacBook-Pro-3","msg":"hello world!"}
```

*pino-systemd-prefix-transport* will write out:

```
<6>{"level":30,"time":1664851979134,"pid":20379,"hostname":"MacBook-Pro-3","msg":"hello world!"}
```

## Usage

```js
const pino = require('pino')
const transport = pino.transport({
  target: 'pino-systemd-prefix-transport',
  level: 'info',
  options: {
    enablePipelining: false, // optional (default: true)
    destination: 1, // optional (default: stdout)
  }
})
pino(transport)
```

There are two configurable properties:

+ `enablePipelining`: set to `false` to disable the pino transport pipeline.
+ `destination`: an integer which is used to specify the destination of the log messages. `1` is stdout, `2` is stderr and others numbers must be a file descriptor. This option is used only when the pipelining is disabled.

### Pipelining

This feature is enabled by default and let you to submit the output to another destination at your choice, such as a `socket` using the `pino-socket` module:

```js
const transport = pino.transport({
  pipeline: [
    {
      target: 'pino-systemd-prefix-transport',
      level: 'info',
      options: {
        ... // other options
      }
    },
    {
      target: 'pino-socket',
      options: {
        mode: 'tcp',
        address: '127.0.0.1',
        port: 8001
      }
    }
  ]
})
pino(transport)
```
### Note

[pino legacy transport](https://getpino.io/#/docs/transports?id=legacy-transports)
is not supported.

## License

MIT

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