Skip to content

Commit

Permalink
🚧 WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
maraisr committed May 27, 2024
1 parent 032e755 commit 06704bd
Show file tree
Hide file tree
Showing 5 changed files with 319 additions and 54 deletions.
47 changes: 47 additions & 0 deletions assets/logo_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions assets/logo_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
205 changes: 205 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 20 additions & 54 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
<div align="center">

<samp>

# ![diary](./shots/logo.png)

</samp>

</div>

<div align="left">

**Dear diary, you make my logging so easy**

<a href="https://npm-stat.com/charts.html?package=diary">
<img src="https://badgen.net/npm/dm/diary?color=black&label=npm%20downloads" alt="js downloads">
</a>
<a href="https://licenses.dev/npm/diary">
<img src="https://licenses.dev/b/npm/diary?style=dark" alt="licenses" />
</a>
<a href="https://unpkg.com/diary/">
<img src="https://img.badgesize.io/https://unpkg.com/diary/browser.mjs?compression=gzip&label=gzip&color=black" alt="gzip size" />
</a>
<a href="https://unpkg.com/diary/">
<img src="https://img.badgesize.io/https://unpkg.com/diary/browser.mjs?compression=brotli&label=brotli&color=black" alt="brotli size" />
</a>
![diary](./assets/logo_dark.svg#gh-dark-mode-only)
![diary](./assets/logo_light.svg#gh-light-mode-only)

**Dear _diary_, you make my logging so easy!**

<br>
<br>
Expand All @@ -39,49 +19,35 @@ This is free to use software, but if you do like it, consisder supporting me ❤

</div>

## ⚡ Features
## ⚙️ Install

- No [dependencies](https://npm.anvaka.com/#/view/2d/diary)
- Outstanding [performance](#-benchmark)
- Support for [`debug`'s filter](https://www.npmjs.com/package/debug#wildcards)
> Avaliable on [jsr](https://jsr.io/@mr/log), [NPM](https://npmjs.com/package/diary) and
> [deno.land](https://deno.land/x/diary)
## ⚙️ Install
[![licenses](https://licenses.dev/b/npm/diary?style=dark)](https://licenses.dev/npm/diary)

```sh
```shell
npm add diary
```

## 🚀 Usage

```ts
import { diary, enable, info } from 'diary';
import { diary } from 'diary'
import { pretty } from 'diary/output.console'

// 1️⃣ Choose to enable the emission of logs, or not.
enable('*');
let user = { name: 'marais', type: 'admin' }

// 2️⃣ log something
info('this important thing happened');
// ~> ℹ info this important thing happened

// Maybe setup a scoped logger
const scopedDiary = diary('my-module', (event) => {
if (event.level === 'error') {
Sentry.captureException(event.error);
}
});

// 3️⃣ log more things
scopedDiary.info('this other important thing happened');
// ~> ℹ info [my-module] this other important thing happened
```
// 1️⃣ create a diary
let log = diary(pretty)

<details><summary>Node users</summary>

The `enable` function is executed for you from the `DEBUG` environment variable. And as a drop in
replacement for `debug`.
// 2️⃣ log something
log('info', '{name} is now {type}', { name: 'marais', type: 'admin' })
// ~> ℹ info marais is now admin

```shell
DEBUG=client:db,server:* node example.js
// 💡 log message as completely typesafe
log('debug', '{name} was created {at}', { name: 'marais' })
// ^? Error: 'at' is not defined
```

</details>
Expand Down
Binary file removed shots/logo.png
Binary file not shown.

0 comments on commit 06704bd

Please sign in to comment.