@orion-js/logger 3.1.0-alpha.10 → 3.1.0-alpha.13
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/lib/helpers/getFileName.js +12 -4
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -0
- package/lib/logger.d.ts +2 -10
- package/lib/logger.js +2 -4
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.js +2 -0
- package/package.json +2 -2
|
@@ -2,16 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setFileName = exports.improveFileName = exports.getFileName = void 0;
|
|
4
4
|
const getFileName = () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
try {
|
|
6
|
+
const stack = new Error().stack;
|
|
7
|
+
const lines = stack.split('\n');
|
|
8
|
+
const filePath = lines[4].split('(')[1].split(')')[0];
|
|
9
|
+
return (0, exports.improveFileName)(filePath);
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
9
14
|
};
|
|
10
15
|
exports.getFileName = getFileName;
|
|
11
16
|
const improveFileName = (path) => {
|
|
12
17
|
if (path.includes('orionjs/packages')) {
|
|
13
18
|
return path.replace(/^.+\/orionjs\/packages\//, '@orion-js/');
|
|
14
19
|
}
|
|
20
|
+
if (path.includes('.orion/build')) {
|
|
21
|
+
return path.replace(/^.+\.orion\/build\//, '');
|
|
22
|
+
}
|
|
15
23
|
return path;
|
|
16
24
|
};
|
|
17
25
|
exports.improveFileName = improveFileName;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -9,6 +9,13 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
12
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.winston = void 0;
|
|
17
|
+
const winston_1 = __importDefault(require("winston"));
|
|
18
|
+
exports.winston = winston_1.default;
|
|
13
19
|
__exportStar(require("./formats"), exports);
|
|
14
20
|
__exportStar(require("./logger"), exports);
|
|
21
|
+
__exportStar(require("./types"), exports);
|
package/lib/logger.d.ts
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import winston from 'winston';
|
|
2
|
+
import { OrionLogger } from './types';
|
|
3
3
|
export declare const winstonLogger: winston.Logger;
|
|
4
4
|
export declare const configureLogger: (options: winston.LoggerOptions) => void;
|
|
5
5
|
export declare const setLogLevel: (level: string) => string;
|
|
6
6
|
export declare const addTransport: (transport: winston.transport) => winston.Logger;
|
|
7
7
|
export declare const getLogger: (context: string) => winston.Logger;
|
|
8
|
-
export declare const logger:
|
|
9
|
-
debug: (message: string, metadata?: any) => winston.Logger;
|
|
10
|
-
info: (message: string, metadata?: any) => winston.Logger;
|
|
11
|
-
warn: (message: string, metadata?: any) => winston.Logger;
|
|
12
|
-
error: (message: string, metadata?: any) => winston.Logger;
|
|
13
|
-
addContext: (module: NodeJS.Module) => any;
|
|
14
|
-
addMetadata: (metadata: any) => any;
|
|
15
|
-
};
|
|
16
|
-
export declare const addModuleContext: (moduleName: string, metadata: any) => void;
|
|
8
|
+
export declare const logger: OrionLogger;
|
package/lib/logger.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.logger = exports.getLogger = exports.addTransport = exports.setLogLevel = exports.configureLogger = exports.winstonLogger = void 0;
|
|
4
4
|
const winston_1 = require("winston");
|
|
5
5
|
const formats_1 = require("./formats");
|
|
6
6
|
const getFileName_1 = require("./helpers/getFileName");
|
|
7
7
|
const transports = [
|
|
8
|
-
process.env.ORION_DEV ? formats_1.textConsoleTransport : formats_1.jsonConsoleTransport
|
|
8
|
+
process.env.ORION_DEV || process.env.JEST_WORKER_ID ? formats_1.textConsoleTransport : formats_1.jsonConsoleTransport
|
|
9
9
|
];
|
|
10
10
|
exports.winstonLogger = (0, winston_1.createLogger)({
|
|
11
11
|
levels: winston_1.config.npm.levels,
|
|
@@ -61,5 +61,3 @@ const createLogger = (logger) => {
|
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
63
|
exports.logger = createLogger(exports.winstonLogger);
|
|
64
|
-
const addModuleContext = (moduleName, metadata) => { };
|
|
65
|
-
exports.addModuleContext = addModuleContext;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare type LogFunction = (message: string, metadata?: any) => void;
|
|
3
|
+
export interface OrionLogger {
|
|
4
|
+
debug: LogFunction;
|
|
5
|
+
info: LogFunction;
|
|
6
|
+
warn: LogFunction;
|
|
7
|
+
error: LogFunction;
|
|
8
|
+
addContext: (module: NodeJS.Module) => OrionLogger;
|
|
9
|
+
addMetadata: (metadata: any) => OrionLogger;
|
|
10
|
+
}
|
package/lib/types/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orion-js/logger",
|
|
3
|
-
"version": "3.1.0-alpha.
|
|
3
|
+
"version": "3.1.0-alpha.13",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "nicolaslopezj",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "9c815a15f5f4babc6de240e26244f09424fbc716"
|
|
29
29
|
}
|