Skip to content

Commit 40c39e6

Browse files
committed
fix(node): ProcLog types
1 parent b909cf8 commit 40c39e6

File tree

6 files changed

+38
-17
lines changed

6 files changed

+38
-17
lines changed

src/LogBase.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const time = {
1414

1515
/**
1616
* @typedef {import('./utils.js').Level} Level
17-
*
17+
*/
18+
/**
1819
* @typedef {object} ExtLogBaseOptions
1920
* @property {Level} [level] log level
2021
* @property {string} [namespaces] namespaces for logging
@@ -25,7 +26,8 @@ const time = {
2526
* @property {number} [spaces] number of spaces for pretty print JSON
2627
* @property {boolean} [splitLine] split lines for pretty "debug" like output (not recommended for prod use)
2728
* @property {object} [serializers] serializers to be applied on object properties
28-
*
29+
*/
30+
/**
2931
* @typedef {import('./Format.js').FormatOption} FormatOption
3032
* @typedef {FormatOption & ExtLogBaseOptions} LogBaseOptions
3133
*/

src/ProcLog.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { LogBase } from './LogBase.js'
22
import { Log } from './node.js'
33
import { inspectOpts, inspectNamespaces, INFO } from './utils.js'
44

5+
/** @typedef {import('./utils.js').Level} Level */
6+
/** @typedef {import('./node.js').LogOptions} LogOptions */
7+
/** @typedef {LogOptions & {Log: typeof Log}} LogOptionsWithCustomLog */
58
/**
6-
* @typedef {import('./node.js').LogOptions} LogOptions
7-
*/
8-
/**
9-
* @typedef {LogOptions & {Log: typeof Log}} LogOptionsWithCustomLog
9+
* @typedef {object} ProcLogOptions
10+
* @property {Level} [level] log level
11+
* @property {string} [namespaces] namespaces for logging
1012
*/
1113

1214
export const EVENT_NAME = 'log-level'
@@ -50,8 +52,8 @@ const defaultOptions = {
5052
export class ProcLog extends LogBase {
5153
/**
5254
* creates a new logger
53-
* @param {String} name - namespace of Logger
54-
* @param {LogOptions} [opts] - see Log.options
55+
* @param {string} name - namespace of Logger
56+
* @param {ProcLogOptions} [opts] - see Log.options
5557
*/
5658
constructor(name, opts) {
5759
const _opts = {

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/** @typedef {import('./node.js').LogOptions & {Log: typeof Log}} LogOptions */
33
/** @typedef {import('./node.js').LogOptionWrapConsole} LogOptionWrapConsole */
44
/** @typedef {import('./node.js').LogOptionHandleExitEvents} LogOptionHandleExitEvents */
5+
/** @typedef {import('./ProcLog.js').ProcLogOptions} ProcLogOptions */
56
/** @typedef {import('./ecs/LogEcs.js').LogOptionsEcs} LogOptionsEcs */
67
/** @typedef {import('./browserLogs.js').MwLogOption} MwLogOption */
78
/** @typedef {import('./httpLogs.js').LogOptionsHttpLog} LogOptionsHttpLog */

types/LogBase.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @typedef {import('./utils.js').Level} Level
3-
*
3+
*/
4+
/**
45
* @typedef {object} ExtLogBaseOptions
56
* @property {Level} [level] log level
67
* @property {string} [namespaces] namespaces for logging
@@ -11,7 +12,8 @@
1112
* @property {number} [spaces] number of spaces for pretty print JSON
1213
* @property {boolean} [splitLine] split lines for pretty "debug" like output (not recommended for prod use)
1314
* @property {object} [serializers] serializers to be applied on object properties
14-
*
15+
*/
16+
/**
1517
* @typedef {import('./Format.js').FormatOption} FormatOption
1618
* @typedef {FormatOption & ExtLogBaseOptions} LogBaseOptions
1719
*/

types/ProcLog.d.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
* @param {LogOptionsWithCustomLog} [options]
44
*/
55
export function initProcLog(options?: LogOptionsWithCustomLog): void;
6+
/** @typedef {import('./utils.js').Level} Level */
7+
/** @typedef {import('./node.js').LogOptions} LogOptions */
8+
/** @typedef {LogOptions & {Log: typeof Log}} LogOptionsWithCustomLog */
69
/**
7-
* @typedef {import('./node.js').LogOptions} LogOptions
8-
*/
9-
/**
10-
* @typedef {LogOptions & {Log: typeof Log}} LogOptionsWithCustomLog
10+
* @typedef {object} ProcLogOptions
11+
* @property {Level} [level] log level
12+
* @property {string} [namespaces] namespaces for logging
1113
*/
1214
export const EVENT_NAME: "log-level";
1315
/**
@@ -44,14 +46,25 @@ export const EVENT_NAME: "log-level";
4446
export class ProcLog extends LogBase {
4547
/**
4648
* creates a new logger
47-
* @param {String} name - namespace of Logger
48-
* @param {LogOptions} [opts] - see Log.options
49+
* @param {string} name - namespace of Logger
50+
* @param {ProcLogOptions} [opts] - see Log.options
4951
*/
50-
constructor(name: string, opts?: LogOptions);
52+
constructor(name: string, opts?: ProcLogOptions);
5153
}
54+
export type Level = import("./utils.js").Level;
5255
export type LogOptions = import("./node.js").LogOptions;
5356
export type LogOptionsWithCustomLog = LogOptions & {
5457
Log: typeof Log;
5558
};
59+
export type ProcLogOptions = {
60+
/**
61+
* log level
62+
*/
63+
level?: import("./utils.js").Level | undefined;
64+
/**
65+
* namespaces for logging
66+
*/
67+
namespaces?: string | undefined;
68+
};
5669
import { LogBase } from './LogBase.js';
5770
import { Log } from './node.js';

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type LogOptions = import("./node.js").LogOptions & {
55
};
66
export type LogOptionWrapConsole = import("./node.js").LogOptionWrapConsole;
77
export type LogOptionHandleExitEvents = import("./node.js").LogOptionHandleExitEvents;
8+
export type ProcLogOptions = import("./ProcLog.js").ProcLogOptions;
89
export type LogOptionsEcs = import("./ecs/LogEcs.js").LogOptionsEcs;
910
export type MwLogOption = import("./browserLogs.js").MwLogOption;
1011
export type LogOptionsHttpLog = import("./httpLogs.js").LogOptionsHttpLog;

0 commit comments

Comments
 (0)