README fixes, new RoundedLocal time format, more local source options
* i wanted to make sure `undefined` was handled properly. seems like it is. * tested with Bun, works. Deno runs faster though, by about 1.8µs/message construction! * Removed skeletons from closet (bug fixes) * Sources can now optionally specify their own time format and/or log timing * Requests and Responses now can be converted and displayed (no bodies)
This commit is contained in:
27
README.md
27
README.md
@@ -66,7 +66,7 @@ Callback ran when a message is logged anywhere (this time components are split u
|
||||
```ts
|
||||
LoggingListeners.onmsg('type', (msg, type, source, time) => {
|
||||
// msg: string
|
||||
// type: MessageType - import { MessageType } from "@proxnet/undead-logging";)
|
||||
// type: MessageType - import { MessageType } from "@proxnet/undead-logging";
|
||||
// source: string
|
||||
// time: Date
|
||||
});
|
||||
@@ -74,25 +74,26 @@ LoggingListeners.onmsg('type', (msg, type, source, time) => {
|
||||
|
||||
Remove callback:
|
||||
```ts
|
||||
const cb = msg => { /* do something with msg */ };
|
||||
const cb = msg => { /* do something with msg: string */ };
|
||||
LoggingListeners.onmsg('basic', cb);
|
||||
LoggingListeners.offmsg('basic', cb);
|
||||
```
|
||||
|
||||
## Time display modes
|
||||
|
||||
You can display three different formats for time:
|
||||
You can display four different formats for time:
|
||||
* UTC
|
||||
* Unix time (in milliseconds)
|
||||
* Local [process] time (in seconds, from the `performance` API)
|
||||
* Local [process] time (in milliseconds, from the `performance` API)
|
||||
* RoundedLocal: Same as above, but rounded to the nearest whole ms
|
||||
|
||||
Set the time format:
|
||||
```ts
|
||||
import { LoggingConfiguration, TimeFormat } from "@proxnet/undead-logging";
|
||||
|
||||
LoggingConfiguration.timeFormat = TimeFormat.Local
|
||||
LoggingConfiguration.timeFormat = TimeFormat.Local;
|
||||
// or
|
||||
LoggingConfiguration.timeFormat = TimeFormat.Utc
|
||||
LoggingConfiguration.timeFormat = TimeFormat.Utc;
|
||||
```
|
||||
|
||||
## (advanced) Logging timing
|
||||
@@ -101,6 +102,14 @@ You can control when log functions are executed using `LoggingConfiguration.logT
|
||||
|
||||
Logs are sent synchronously by default. You can optionally defer logs with `setImmediate` using `LogTiming.Deferred`
|
||||
```ts
|
||||
LoggingConfiguration.logTiming = LogTiming.Sync
|
||||
LoggingConfiguration.logTiming = LogTiming.Deferred
|
||||
```
|
||||
LoggingConfiguration.logTiming = LogTiming.Sync;
|
||||
// or
|
||||
LoggingConfiguration.logTiming = LogTiming.Deferred;
|
||||
```
|
||||
|
||||
## [Benchmarks](./BENCH.md)
|
||||
|
||||
## Contributing
|
||||
Are you crazy? This ol' thing is just.. "meh" at most. You're sure?
|
||||
|
||||
... anyway, create an account on gitea.proxnet.dev, fork, then PR.
|
||||
Reference in New Issue
Block a user