# tcp-log-client

> stream and write tcp-log-server entries

Latest version **6.0.0** (published 2019-07-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install tcp-log-client
pnpm add tcp-log-client
yarn add tcp-log-client
bun add tcp-log-client
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2019-07-02 |
| First published | 2016-07-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kyle E. Mitchell |
| Maintainers | kemitchell |
| Keywords | TCP, client, database, kappa, log |

## Links

- npm: https://www.npmjs.com/package/tcp-log-client
- Repository: https://github.com/kemitchell/tcp-log-client.js
- Homepage: https://github.com/kemitchell/tcp-log-client.js#readme
- Issues: https://github.com/kemitchell/tcp-log-client.js/issues
- npm.io page: https://npm.io/package/tcp-log-client

## Dependencies (5)

- [pump](https://npm.io/package/pump.md) ^3.0.0
- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [ndjson](https://npm.io/package/ndjson.md) ^1.4.3
- [through2](https://npm.io/package/through2.md) ^3.0.1
- [reconnect-core](https://npm.io/package/reconnect-core.md) ^1.3.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 6.0.0 (latest) — 2019-07-02
- 5.0.0 — 2016-07-23
- 4.0.0 — 2016-07-11
- 3.1.0 — 2016-07-11
- 3.0.0 — 2016-07-10
- 2.0.0 — 2016-07-05
- 1.0.0 — 2016-07-04

## README

Stream and write [tcp-log-server] entries.  Reconnect automatically.

[tcp-log-server]: https://npmjs.com/packages/tcp-log-server

```javascript
var TCPLogClient = require('tcp-log-client')

var client = new TCPLogClient({
  // Use these options for `require('net').connect(options)`.
  server: {port: port},
  // Enable TCP keepalive. Enabled by default.
  keepAlive: true,
  // Disable the Nagle algorithm. Disabled by default.
  noDelay: true,
  // Start reading from entry index 1. 1 by default.
  from: 1,
  // Stop trying to reconnect and fail after 5 attempts.
  reconnect: {failAfter: 5}
})
  .on('error', function (error) {
    console.error(error)
  })
  .on('fail', function () {
    console.error('Failed to reconnect.')
  })
  .once('ready', function () {
    if (client.connected) {
      client.write({example: 'entry'}, function (error, index) {
        console.log('New entry index is %d', index)
        // Permanently disconnect and end `client.readStream`.
        client.destroy()
      })
    }
  })

// Readable stream of log entries.
// Entries added with `client.write()` will be streamed, too.
client.readStream.on('data', function (chunk) {
  console.log(chunk.index)
  console.log(chunk.entry)
})
```

See also:

- [net documentation](https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener) for `options.server`
- [reconnect-core](https://www.npmjs.com/package/reconnect-core) for `options.reconnect`
- [migrate-versioned-log](https://www.npmjs.com/package/migrate-versioned-log) for versioning log entries

---
_Source: https://npm.io/package/tcp-log-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
