Skip to content

Commit 58424b9

Browse files
committed
docs: Add kitchensink example generator and screenshot to readme
1 parent e5214c2 commit 58424b9

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Features:
2020
* Add or use your own streams for destinations
2121
* All pino-pretty configs are exposed and extensible
2222

23+
<img src="/example/example.png"
24+
alt="log output example" height="500">
25+
2326
# Install
2427

2528
```
@@ -225,7 +228,7 @@ import {
225228
buildDestinationStdout, // stream to STDOUT
226229
buildDestinationStderr, // stream to STDERR
227230
buildDestinationFile, // write to static file
228-
buildDestinationRollingFile // write to rolling
231+
buildDestinationRollingFile // write to rolling file
229232
} from "@foxxmd/logging/factory";
230233
```
231234

@@ -234,7 +237,7 @@ All `buildDestination` functions take args:
234237
* `level` (first arg) - minimum level to log at
235238
* `options` (second arg) - an object extending [`pino-pretty` options](https://github.com/pinojs/pino-pretty?tab=readme-ov-file#options)
236239

237-
`options` inherits a default `pino-pretty` configuration that makes comprises `@foxxmd/logging`'s opinionated logging format. The common default config can be generated using `prettyOptsFactory` which accepts an optional [`pino-pretty` options](https://github.com/pinojs/pino-pretty?tab=readme-ov-file#options) object to override defaults:
240+
`options` inherits a default `pino-pretty` configuration that comprises `@foxxmd/logging`'s opinionated logging format. The common default config can be generated using `prettyOptsFactory` which accepts an optional [`pino-pretty` options](https://github.com/pinojs/pino-pretty?tab=readme-ov-file#options) object to override defaults:
238241

239242
```ts
240243
import { prettyOptsFactory } from "@foxxmd/logging/factory";

example/example.png

138 KB
Loading

example/kitchenSink.ts

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {childLogger, loggerApp, loggerDebug} from '../src/index.js'
2+
import {ErrorWithCause} from "pony-cause";
3+
import process from "process";
4+
import path from 'path';
5+
6+
const initLogger = childLogger(loggerDebug, 'Init');
7+
initLogger.info('Initializing Application -> v1.3.1');
8+
initLogger.debug('Debug logging is enabled!');
9+
initLogger.debug(`Found Log Config at ${path.resolve(process.cwd(), './config.yaml')}`)
10+
11+
const appLogger = loggerApp({file: false});
12+
const logger = childLogger(appLogger, 'App');
13+
logger.verbose(`Logging to -> ${path.resolve(process.cwd(), './logs/app.log')}`);
14+
15+
const nestedChild1 = childLogger(logger, 'Service A');
16+
nestedChild1.log('Starting monitoring for events...');
17+
18+
const nestedChild2 = childLogger(nestedChild1, ['Queue', 'Parser']);
19+
nestedChild2.warn('Unexpected contents found in event, skipping');
20+
21+
const siblingLogger = childLogger(logger, ['Service B', 'Manager']);
22+
siblingLogger.info('Widget allocation has initiated');
23+
24+
logger.debug({myProp: 'a string', nested: {anotherProps: ['val1', 'val2'], boolProp: true}}, 'Test');
25+
26+
const er = new Error('A configuration error occurred');
27+
const causeErr = new ErrorWithCause('Service C did not start', {cause: er});
28+
logger.error(causeErr);
29+
30+
logger.verbose('(1) service failed to start but is non-essential...continuing startup')
31+
logger.info('Application successfully started and running!')

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"build": "tsc",
1010
"prepare": "tshy",
1111
"test": "mocha --reporter spec --recursive ./tests/*.test.ts",
12-
"postinstall": "patch-package"
12+
"postinstall": "patch-package",
13+
"example": "tsx example/kitchenSink.ts"
1314
},
1415
"keywords": [],
1516
"author": "FoxxMD",

0 commit comments

Comments
 (0)