# @coboxcoop/log

> log for application layer messages

Latest version **1.0.6-alpha.1** (published 2022-04-07) · AGPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @coboxcoop/log
pnpm add @coboxcoop/log
yarn add @coboxcoop/log
bun add @coboxcoop/log
```

## Health

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

Positive: no vulnerabilities.

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

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6-alpha.1 |
| Published | 2022-04-07 |
| First published | 2020-07-29 |
| Weekly downloads | 0 |
| License | AGPL-3.0-or-later |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 50.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | magma collective |
| Maintainers | kyphae, ameba23 |
| Keywords | cobox, log, hypercore |

## Links

- npm: https://www.npmjs.com/package/@coboxcoop/log
- Repository: https://gitlab.com/coboxcoop/log
- Homepage: https://cobox.cloud
- Issues: https://gitlab.com/coboxcoop/log/issues
- npm.io page: https://npm.io/package/@coboxcoop/log

## Dependencies (13)

- [debug](https://npm.io/package/debug.md) ^4.1.1
- [hypertrie](https://npm.io/package/hypertrie.md) ^5.0.5
- [kappa-core](https://npm.io/package/kappa-core.md) github:Frando/kappa-core#exp-0.2.3
- [lodash.get](https://npm.io/package/lodash.get.md) ^4.4.2
- [nanoresource](https://npm.io/package/nanoresource.md) ^1.3.0
- [subleveldown](https://npm.io/package/subleveldown.md) ^5.0.0
- [call-me-maybe](https://npm.io/package/call-me-maybe.md) ^1.0.1
- [collect-stream](https://npm.io/package/collect-stream.md) ^1.2.1
- [kappa-view-query](https://npm.io/package/kappa-view-query.md) ^3.0.1
- [@coboxcoop/crypto](https://npm.io/package/@coboxcoop/crypto.md) ^1.0.2-alpha.1
- [@coboxcoop/logger](https://npm.io/package/@coboxcoop/logger.md) 1.0.1-alpha.1
- [@coboxcoop/schemas](https://npm.io/package/@coboxcoop/schemas.md) ^1.0.0-alpha.1
- [kappa-sparse-indexer](https://npm.io/package/kappa-sparse-indexer.md) 0.6.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

- 1.0.6-alpha.1 (latest) — 2022-04-07
- 1.0.5-alpha.1 — 2021-06-11
- 1.0.4-alpha.1 — 2020-07-29
- 1.0.3-alpha.1 — 2020-07-29
- 1.0.2-alpha.1 — 2020-07-29
- 1.0.1-alpha.1 — 2020-07-29
- 1.0.0-alpha.1 — 2020-07-29

## README

# log

<div align="center">
  <img src="https://cobox.cloud/src/svg/logo.svg">
</div>

[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)

## Table of Contents

  - [About](#about)
  - [Install](#install)
  - [Usage](#usage)
  - [API](#api)
  - [Contributing](#contributing)
  - [License](#license)

## About
**CoBox** is an encrypted p2p file system and distributed back-up tool. [README](https://gitlab.com/coboxcoop/readme) provides a map of the project.

`log` provides a multifeed source for all cobox logs. Uses `kappa-core@experimental` and `kappa-view-query` to establish a queryable set of indices.

A cobox-log hypercore feed is initially appended with a `hypertrie` header, that simply gives the feed the name `log`. This allows other peers to identify what kind of content the feed holds and index the feed correctly, and vice-versa, allows you to index other peer's log feeds correctly.

A CoBox log can be identified with a header appended as the first entry to the feed.

## Install 
```
npm i -g @coboxcoop/log
```

## Usage

```js
const Kappa = require('kappa-core')
const multifeed = require('multifeed')
const { Header } = require('hypertrie/lib/messages')
const crypto = require('hypercore-crypto')
const mkdirp = require('mkdirp')
const tmpdir = require('tmpdir')
const level = require('level')

const tmp = tmpdir().name
mkdirp.sync(tmp)

// author is a global keypair used to sign all records
// it is more akin to an identity than a log's signing keypairs
// in cobox, this is derived from a parent key

// var author = crypto.keyPair().publicKey
var author = '5c448d8aecdc013d9145b6e936f9b255434e7f9e728213486f0b18f211512fb2'

const log = new Log({
  core: new Kappa(),
  feeds: multifeed(ram),
  keyPair: crypto.keyPair(),
  author,
  db: level(tmp)
})

log.get(0, (err, payload) => {
  Header.decode(payload)
  // { type: 'log', metadata: null }
})

var msg = {
  type: 'peer/about',
  version: '1.0.0',
  timestamp: 1580813687256,
  author,
  content: { name: 'magpie' }
}

log.publish(payload, { valueEncoding: PeerAbout }, (err, msg) => {
  // {
  //   key: '031fb3bd3c2571a7ca54a01a1021e374fd63d0b56b1a9ab142b9ae7a24287dc8@1',
  //   seq: 1,
  //   value: {
  //     type: 'peer/about',
  //     timestamp: 1580813687256,
  //     author: '5c448d8aecdc013d9145b6e936f9b255434e7f9e728213486f0b18f211512fb2',
  //     content: {
  //       name: 'magpie'
  //     }
  //   }
  // }
})
```

## API
See swagger documentation... (we won't have this for a while).

## Contributing

PRs accepted.

Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.

# License

[`AGPL-3.0-or-later`](./LICENSE)

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