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 fb01ff6 commit 1824f85
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 130 deletions.
86 changes: 35 additions & 51 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.
86 changes: 35 additions & 51 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.
35 changes: 17 additions & 18 deletions examples/_journey.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import type { Diary } from '../src/mod.ts';

import {faker} from 'npm:@faker-js/faker';
import { faker } from 'npm:@faker-js/faker';

export function log_journey(log: Diary) {
setInterval(() => {
let user = {
name: faker.person.fullName(),
};
setInterval(() => {
let user = {
name: faker.person.fullName(),
};

log('info', 'Creating user {name}', user);
if (Math.random() > 0.5) log('warn', 'User {name} already exists', user);
log('info', 'Creating user {name}', user);
if (Math.random() > 0.5) log('warn', 'User {name} already exists', user);

let order = {
id: faker.string.uuid(),
total: faker.commerce.price(),
}
let order = {
id: faker.string.uuid(),
total: faker.commerce.price(),
};

log('info', '{name} placed an order {id} with {total}', {
...order,
...user
});

},500);
}
log('info', '{name} placed an order {id} with {total}', {
...order,
...user,
});
}, 500);
}
20 changes: 10 additions & 10 deletions examples/stream.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { LogEvent } from "../src/mod.ts";
import { diary } from "../src/stream.ts";
import { interpolate } from "../src/utils.ts";
import type { LogEvent } from '../src/mod.ts';
import { diary } from '../src/stream.ts';
import { interpolate } from '../src/utils.ts';
import { log_journey } from './_journey.ts';

let log_file = await Deno.open("./log.log", {
let log_file = await Deno.open('./log.log', {
write: true,
create: true,
truncate: true,
truncate: true,
});

let log_transform = new TransformStream<LogEvent, string>({
Expand All @@ -18,11 +18,11 @@ let log_transform = new TransformStream<LogEvent, string>({
let log = diary((readable) => {
let [a, b] = readable
.pipeThrough(log_transform)
.pipeThrough(new TextEncoderStream())
.tee();
a.pipeTo(log_file.writable);
b.pipeTo(Deno.stdout.writable);
.pipeThrough(new TextEncoderStream())
.tee();

a.pipeTo(log_file.writable);
b.pipeTo(Deno.stdout.writable);
});

log_journey(log);

0 comments on commit 1824f85

Please sign in to comment.