# lokalo

> ![](fixtures/message-expanded.png?raw=true)

Latest version **0.0.7** (published 2022-05-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install lokalo
pnpm add lokalo
yarn add lokalo
bun add lokalo
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2022-05-13 |
| First published | 2022-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 441.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Blujedis LLC blujedicorp@gmail.com |
| Maintainers | blujedis |
| Keywords | localStorage, sessionStorage, log, json |

## Links

- npm: https://www.npmjs.com/package/lokalo
- Repository: https://github.com/blujedis/lokalo
- Homepage: https://github.com/blujedis/lokalo#readme
- Issues: https://github.com/blujedis/lokalo/issues
- npm.io page: https://npm.io/package/lokalo

## Dependencies (1)

- [dot-prop](https://npm.io/package/dot-prop.md) ^7.1.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.7 (latest) — 2022-05-13
- 0.0.6 — 2022-05-12
- 0.0.5 — 2022-05-12
- 0.0.4 — 2022-05-12
- 0.0.3 — 2022-05-12
- 0.0.2 — 2022-01-30

## README

# Lokalo

![](fixtures/message-expanded.png?raw=true)  

Client side logging utility that logs to session or local storage. This is useful when you are tracking down client side bugs among other things. At a later time you can create a view where the user can upload these logs automatically. Perhpaps then forward on to Graylog or some other logging service.

## Gettin Started

Install Lokalo in your dependencies.

```sh
npm install lokalo
```
or 
```sh
yarn add lokalo
```

## Using Default Instance

For ease of use Lokalo has a default instance you can use which sets the log level to ```error```, meaning only ```logger.log``` or ```logger.error``` methods will be logged. This is generally what you want as other log levels are more development related. If you wish to change this simply create your own instance. The default instance also initializes with the namespace ```lokalo```. This is the name the log messages will be stored under in your storage item.

```ts
import logger from 'lokalo';
logger.log('some message'); // this will always be displayed.
logger.fatal('some elevated error message'); // or you can log an Error instance.
logger.error('some error'); // or you can log an Error instance.
logger.warn('log a warning');
logger.info('log an info message');
logger.debug('shown when debug is enabled');
```

## Creating Instance

You can create your own instance of Lokalo.

```ts
import { Lokalo } from 'lokalo';
const logger = new Lokalo({
  namespace: 'your_namespace',
  level: 'debug', // can be 'error', 'warn', 'info', 'debug'
});
```

## Options

Options can only be provided when defining your own custom instance. For more information and details of each implementation see [Generated Docs](#docs)

<table>
  <thead>
    <tr><th>Property</th><th>Type</th><th>Default</th></tr>
  </thead>
  <tbody>
    <tr><td>type</td><td>string</td><td>lokalo</td></tr>
    <tr><td>namespace</td><td>string</td><td>lokalo</td></tr>
    <tr><td>level</td><td>LogLevel</td><td>error</td></tr>
    <tr><td>maxLines</td><td>number</td><td>50</td></tr>
    <tr><td>displayOutput</td><td>boolean</td><td>true</td></tr>
    <tr><td>styles</td><td>object</td><td><a href="#default-log-styles">See Styles</a></td></tr>
    <tr><td>uid</td><td>Function</td><td>()=> uuidv4()</td></tr>
  </tbody>
</table>

## Child Logger

You can also create child loggers. To do so simply call the child method and provide the child namespace. The parent will be set automatically.

```ts
import logger from 'lokalo';
const child = logger.child('admin');
```

## Default Log Styles

You can provide a named color, rgb or hex color that Lokalo will use when displaying message in your browser's inspector.

```ts
export const STYLES = {
  inherit: 'color: inherit',
  dim: 'color: #666',
  log: 'color: lightslategray',
  fatal: 'color: red',
  error: 'color: firebrick',
  warn: 'color: gold',
  info: 'color: deepskyblue',
  debug: 'color: magenta'
};
```

## Examples

A few examples of what output looks like in your terminal.

### Message
![](fixtures/message.png?raw=true)  

### Message Expanded (shows payload)
![](fixtures/message-expanded.png?raw=true)  

### All Loggers (with Array of Messages)
![](fixtures/all.png?raw=true)  

## Docs

See [https://blujedis.github.io/lokalo/](https://blujedis.github.io/lokalo/)

## License

See [LICENSE.md](LICENSE)

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