Skip to content

Commit

Permalink
Having child on extras provides better developer experience
Browse files Browse the repository at this point in the history
  • Loading branch information
kibertoad committed Aug 26, 2021
1 parent 6a9d48e commit 2fbfc80
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions pino.d.ts
Expand Up @@ -730,18 +730,6 @@ declare namespace P {
type Logger = BaseLogger & LoggerExtras & Record<string, any>;

interface BaseLogger {
/**
* Creates a child logger, setting all key-value pairs in `bindings` as properties in the log lines. All serializers will be applied to the given pair.
* Child loggers use the same output stream as the parent and inherit the current log level of the parent at the time they are spawned.
* From v2.x.x the log level of a child is mutable (whereas in v1.x.x it was immutable), and can be set independently of the parent.
* If a `level` property is present in the object passed to `child` it will override the child logger level.
*
* @param bindings: an object of key-value pairs to include in log lines as properties.
* @param options: an options object that will override child logger inherited options.
* @returns a child logger instance.
*/
child(bindings: Bindings, options?: ChildLoggerOptions): BaseLogger;

/**
* Set this property to the desired logging level. In order of priority, available levels are:
*
Expand Down Expand Up @@ -850,6 +838,18 @@ declare namespace P {
*/
levelVal: number;

/**
* Creates a child logger, setting all key-value pairs in `bindings` as properties in the log lines. All serializers will be applied to the given pair.
* Child loggers use the same output stream as the parent and inherit the current log level of the parent at the time they are spawned.
* From v2.x.x the log level of a child is mutable (whereas in v1.x.x it was immutable), and can be set independently of the parent.
* If a `level` property is present in the object passed to `child` it will override the child logger level.
*
* @param bindings: an object of key-value pairs to include in log lines as properties.
* @param options: an options object that will override child logger inherited options.
* @returns a child logger instance.
*/
child(bindings: Bindings, options?: ChildLoggerOptions): Logger;

/**
* Registers a listener function that is triggered when the level is changed.
* Note: When browserified, this functionality will only be available if the `events` module has been required elsewhere
Expand Down
2 changes: 1 addition & 1 deletion test/types/pino.test-d.ts
Expand Up @@ -93,7 +93,7 @@ child.level = "info";
child.info("hooray");
log.info("nope nope nope");
log.child({ foo: "bar" }, { level: "debug" }).debug("debug!");
(child as Logger).bindings();
child.bindings();
const customSerializers = {
test() {
return "this is my serializer";
Expand Down

0 comments on commit 2fbfc80

Please sign in to comment.