@orion-js/logger 3.1.0-alpha.11 → 3.1.0-alpha.14
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 +19 -4
- package/lib/helpers/getFileName.test.d.ts +1 -0
- package/lib/helpers/getFileName.test.js +15 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/logger.d.ts +2 -9
- package/lib/logger.js +1 -1
- package/lib/types/index.d.ts +10 -0
- package/lib/types/index.js +2 -0
- package/package.json +2 -2
|
@@ -2,10 +2,15 @@
|
|
|
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) => {
|
|
@@ -15,6 +20,16 @@ const improveFileName = (path) => {
|
|
|
15
20
|
if (path.includes('.orion/build')) {
|
|
16
21
|
return path.replace(/^.+\.orion\/build\//, '');
|
|
17
22
|
}
|
|
23
|
+
if (path.includes('/node_modules/@')) {
|
|
24
|
+
const after = path.split('/node_modules/')[1];
|
|
25
|
+
const parts = after.split('/');
|
|
26
|
+
return `${parts[0]}/${parts[1]}`;
|
|
27
|
+
}
|
|
28
|
+
if (path.includes('/node_modules/')) {
|
|
29
|
+
const after = path.split('/node_modules/')[1];
|
|
30
|
+
const parts = after.split('/');
|
|
31
|
+
return `${parts[0]}`;
|
|
32
|
+
}
|
|
18
33
|
return path;
|
|
19
34
|
};
|
|
20
35
|
exports.improveFileName = improveFileName;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getFileName_1 = require("./getFileName");
|
|
4
|
+
describe('GetFileName', () => {
|
|
5
|
+
it('Should clean @package in node_modules', () => {
|
|
6
|
+
const fileName = '/Users/nicolaslopezj/Code/Projects/justo/drivers/server/node_modules/@orion-js/dogs/lib/services/WorkerService.js:39:25';
|
|
7
|
+
const improvedFileName = (0, getFileName_1.improveFileName)(fileName);
|
|
8
|
+
expect(improvedFileName).toBe('@orion-js/dogs');
|
|
9
|
+
});
|
|
10
|
+
it('Should clean simple package in node modules', () => {
|
|
11
|
+
const fileName = '/Users/nicolaslopezj/Code/Projects/justo/drivers/server/node_modules/dogs/lib/services/WorkerService.js:39:25';
|
|
12
|
+
const improvedFileName = (0, getFileName_1.improveFileName)(fileName);
|
|
13
|
+
expect(improvedFileName).toBe('dogs');
|
|
14
|
+
});
|
|
15
|
+
});
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/logger.d.ts
CHANGED
|
@@ -1,15 +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
|
-
};
|
|
8
|
+
export declare const logger: OrionLogger;
|
package/lib/logger.js
CHANGED
|
@@ -5,7 +5,7 @@ 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,
|
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.14",
|
|
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": "36de6862412659541fbc64d38879995227be4184"
|
|
29
29
|
}
|