@x1-labs/logging 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.d.ts +3 -0
- package/dist/index.browser.js +8 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/level.d.ts +1 -0
- package/dist/level.js +25 -0
- package/dist/level.js.map +1 -0
- package/dist/logger.browser.d.ts +8 -0
- package/dist/logger.browser.js +24 -0
- package/dist/logger.browser.js.map +1 -0
- package/dist/logger.d.ts +8 -0
- package/dist/logger.js +35 -0
- package/dist/logger.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLogger = exports.resolveLogLevel = void 0;
|
|
4
|
+
var level_1 = require("./level");
|
|
5
|
+
Object.defineProperty(exports, "resolveLogLevel", { enumerable: true, get: function () { return level_1.resolveLogLevel; } });
|
|
6
|
+
var logger_browser_1 = require("./logger.browser");
|
|
7
|
+
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return logger_browser_1.createLogger; } });
|
|
8
|
+
//# sourceMappingURL=index.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":";;;AAAA,iCAA0C;AAAjC,wGAAA,eAAe,OAAA;AACxB,mDAAgD;AAAvC,8GAAA,YAAY,OAAA"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLogger = exports.resolveLogLevel = void 0;
|
|
4
|
+
var level_1 = require("./level");
|
|
5
|
+
Object.defineProperty(exports, "resolveLogLevel", { enumerable: true, get: function () { return level_1.resolveLogLevel; } });
|
|
6
|
+
var logger_1 = require("./logger");
|
|
7
|
+
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return logger_1.createLogger; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAA0C;AAAjC,wGAAA,eAAe,OAAA;AACxB,mCAAwC;AAA/B,sGAAA,YAAY,OAAA"}
|
package/dist/level.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveLogLevel(override?: string): string;
|
package/dist/level.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveLogLevel = resolveLogLevel;
|
|
4
|
+
const PINO_LEVELS = new Set([
|
|
5
|
+
'trace',
|
|
6
|
+
'debug',
|
|
7
|
+
'info',
|
|
8
|
+
'warn',
|
|
9
|
+
'error',
|
|
10
|
+
'verbose',
|
|
11
|
+
]);
|
|
12
|
+
function resolveLogLevel(override) {
|
|
13
|
+
if (override)
|
|
14
|
+
return override;
|
|
15
|
+
const logLevel = process.env.LOG_LEVEL;
|
|
16
|
+
const nodeEnv = process.env.NODE_ENV;
|
|
17
|
+
if (logLevel && PINO_LEVELS.has(logLevel)) {
|
|
18
|
+
return logLevel === 'verbose' ? 'trace' : logLevel;
|
|
19
|
+
}
|
|
20
|
+
if (!logLevel && nodeEnv === 'development') {
|
|
21
|
+
return 'debug';
|
|
22
|
+
}
|
|
23
|
+
return 'info';
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=level.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"level.js","sourceRoot":"","sources":["../src/level.ts"],"names":[],"mappings":";;AASA,0CAeC;AAxBD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,SAAS;CACV,CAAC,CAAC;AAEH,SAAgB,eAAe,CAAC,QAAiB;IAC/C,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAE9B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IACvC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;IAErC,IAAI,QAAQ,IAAI,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1C,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,QAAQ,IAAI,OAAO,KAAK,aAAa,EAAE,CAAC;QAC3C,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createLogger = createLogger;
|
|
7
|
+
const pino_1 = __importDefault(require("pino"));
|
|
8
|
+
const level_1 = require("./level");
|
|
9
|
+
function createLogger(options = {}) {
|
|
10
|
+
const level = (0, level_1.resolveLogLevel)(options.level);
|
|
11
|
+
const opts = {
|
|
12
|
+
level,
|
|
13
|
+
browser: { asObject: true },
|
|
14
|
+
formatters: {
|
|
15
|
+
level: (label) => ({ level: label.toUpperCase() }),
|
|
16
|
+
},
|
|
17
|
+
...options.pinoOptions,
|
|
18
|
+
};
|
|
19
|
+
if (options.name) {
|
|
20
|
+
opts.name = options.name;
|
|
21
|
+
}
|
|
22
|
+
return (0, pino_1.default)(opts);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=logger.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.browser.js","sourceRoot":"","sources":["../src/logger.browser.ts"],"names":[],"mappings":";;;;;AAaA,oCAwBC;AArCD,gDAAwB;AAExB,mCAA0C;AAW1C,SAAgB,YAAY,CAC1B,UAKI,EAAE;IAEN,MAAM,KAAK,GAAG,IAAA,uBAAe,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAE7C,MAAM,IAAI,GAAkB;QAC1B,KAAK;QACL,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC3B,UAAU,EAAE;YACV,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;SACnD;QACD,GAAG,OAAO,CAAC,WAAW;KACvB,CAAC;IAEF,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,OAAO,IAAA,cAAI,EAAC,IAAI,CAAC,CAAC;AACpB,CAAC"}
|
package/dist/logger.d.ts
ADDED
package/dist/logger.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createLogger = createLogger;
|
|
7
|
+
const pino_1 = __importDefault(require("pino"));
|
|
8
|
+
const level_1 = require("./level");
|
|
9
|
+
function isJsonOutput(override) {
|
|
10
|
+
if (override !== undefined)
|
|
11
|
+
return override;
|
|
12
|
+
return process.env.LOG_FORMAT === 'json';
|
|
13
|
+
}
|
|
14
|
+
function createLogger(options = {}) {
|
|
15
|
+
const level = (0, level_1.resolveLogLevel)(options.level);
|
|
16
|
+
const json = isJsonOutput(options.json);
|
|
17
|
+
const opts = {
|
|
18
|
+
level,
|
|
19
|
+
formatters: {
|
|
20
|
+
level: (label) => ({ level: label.toUpperCase() }),
|
|
21
|
+
},
|
|
22
|
+
...options.pinoOptions,
|
|
23
|
+
};
|
|
24
|
+
if (options.name) {
|
|
25
|
+
opts.name = options.name;
|
|
26
|
+
}
|
|
27
|
+
if (!json) {
|
|
28
|
+
opts.transport = {
|
|
29
|
+
target: 'pino-pretty',
|
|
30
|
+
options: { singleLine: true },
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return (0, pino_1.default)(opts);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;;;AAgBA,oCAwBC;AAxCD,gDAAwB;AAExB,mCAA0C;AAS1C,SAAS,YAAY,CAAC,QAAkB;IACtC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC5C,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,MAAM,CAAC;AAC3C,CAAC;AAED,SAAgB,YAAY,CAAC,UAA+B,EAAE;IAC5D,MAAM,KAAK,GAAG,IAAA,uBAAe,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC,MAAM,IAAI,GAAkB;QAC1B,KAAK;QACL,UAAU,EAAE;YACV,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;SACnD;QACD,GAAG,OAAO,CAAC,WAAW;KACvB,CAAC;IAEF,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,CAAC,SAAS,GAAG;YACf,MAAM,EAAE,aAAa;YACrB,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE;SAC9B,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,cAAI,EAAC,IAAI,CAAC,CAAC;AACpB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x1-labs/logging",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared pino logging library",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"browser": "dist/index.browser.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"browser": "./dist/index.browser.js",
|
|
11
|
+
"default": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/x1-labs/ts-logging-common.git",
|
|
18
|
+
"directory": "packages/logging"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc -p tsconfig.build.json",
|
|
22
|
+
"prepublishOnly": "bun run build",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"lint": "eslint \"src/**/*.ts\" --fix",
|
|
25
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
26
|
+
"check": "bun run lint && bun run typecheck && bun run format --check"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"pino": "^10.3.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"pino-pretty": "^13.0.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"pino-pretty": {
|
|
36
|
+
"optional": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist"
|
|
41
|
+
],
|
|
42
|
+
"license": "MIT"
|
|
43
|
+
}
|