@emartech/json-logger
Advanced tools
Comparing version 7.1.0 to 7.2.0
@@ -1,1 +0,1 @@ | ||
export declare function isNamespaceEnabled(availableNamespace: string, namespace: string): boolean; | ||
export declare const isNamespaceEnabled: (availableNamespace: string, namespace: string) => boolean; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isNamespaceEnabled = void 0; | ||
function isNamespaceEnabled(availableNamespace, namespace) { | ||
const isNamespaceEnabled = (availableNamespace, namespace) => { | ||
const availableNamespaces = availableNamespace.split(/[\s,]+/); | ||
@@ -9,3 +9,3 @@ let enabled = false; | ||
const skips = []; | ||
availableNamespaces.forEach(function (name) { | ||
availableNamespaces.forEach((name) => { | ||
if (!name) { | ||
@@ -22,3 +22,3 @@ return; | ||
}); | ||
adds.forEach(function (addRegexp) { | ||
adds.forEach((addRegexp) => { | ||
if (addRegexp.test(namespace)) { | ||
@@ -28,3 +28,3 @@ enabled = true; | ||
}); | ||
skips.forEach(function (addRegexp) { | ||
skips.forEach((addRegexp) => { | ||
if (addRegexp.test(namespace)) { | ||
@@ -35,3 +35,3 @@ enabled = false; | ||
return enabled; | ||
} | ||
}; | ||
exports.isNamespaceEnabled = isNamespaceEnabled; |
@@ -1,6 +0,4 @@ | ||
import { jsonFormatter } from './json'; | ||
import { logentriesFormatter } from './logentries'; | ||
export declare const formatter: { | ||
json: typeof jsonFormatter; | ||
logentries: typeof logentriesFormatter; | ||
json: (log: unknown) => string; | ||
logentries: (data: Record<string, unknown>) => string; | ||
}; |
@@ -8,3 +8,3 @@ "use strict"; | ||
json: json_1.jsonFormatter, | ||
logentries: logentries_1.logentriesFormatter | ||
logentries: logentries_1.logentriesFormatter, | ||
}; |
@@ -1,1 +0,1 @@ | ||
export declare function jsonFormatter(log: unknown): string; | ||
export declare const jsonFormatter: (log: unknown) => string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.jsonFormatter = void 0; | ||
function jsonFormatter(log) { | ||
const jsonFormatter = (log) => { | ||
return JSON.stringify(log); | ||
} | ||
}; | ||
exports.jsonFormatter = jsonFormatter; |
@@ -1,1 +0,1 @@ | ||
export declare function logentriesFormatter(data: Record<string, unknown>): string; | ||
export declare const logentriesFormatter: (data: Record<string, unknown>) => string; |
@@ -18,8 +18,7 @@ "use strict"; | ||
}; | ||
function logentriesFormatter(data) { | ||
return Object | ||
.keys(data) | ||
.map(key => convertToTag(data[key], key)) | ||
const logentriesFormatter = (data) => { | ||
return Object.keys(data) | ||
.map((key) => convertToTag(data[key], key)) | ||
.join(' '); | ||
} | ||
}; | ||
exports.logentriesFormatter = logentriesFormatter; |
@@ -9,5 +9,5 @@ import { Logger, LoggerConfig } from './logger/logger'; | ||
var formatter: { | ||
json: typeof import("./formatter/json").jsonFormatter; | ||
logentries: typeof import("./formatter/logentries").logentriesFormatter; | ||
json: (log: unknown) => string; | ||
logentries: (data: Record<string, unknown>) => string; | ||
}; | ||
} |
@@ -23,4 +23,4 @@ import { Timer } from '../timer/timer'; | ||
constructor(namespace: string, enabled: boolean); | ||
static configure(options: LoggerConfig): void; | ||
static _validate(options: LoggerConfig): void; | ||
static configure(options: Partial<LoggerConfig>): void; | ||
static _validate(options: Partial<LoggerConfig>): void; | ||
static config: LoggerConfig; | ||
@@ -27,0 +27,0 @@ isEnabled(): boolean; |
@@ -21,3 +21,3 @@ "use strict"; | ||
static _validate(options) { | ||
Object.keys(options).forEach(key => { | ||
Object.keys(options).forEach((key) => { | ||
if (!allowedKeys.includes(key)) { | ||
@@ -57,3 +57,3 @@ throw new Error('Only the following keys are allowed: formatter, output'); | ||
level: config_1.config.levels[level].number, | ||
time: new Date().toISOString() | ||
time: new Date().toISOString(), | ||
}, data); | ||
@@ -81,5 +81,3 @@ Logger.config.transformers.forEach((transform) => { | ||
} | ||
return stack.length > STACK_TRACE_LIMIT ? | ||
stack.substring(0, STACK_TRACE_LIMIT) + ' ...' : | ||
stack; | ||
return stack.length > STACK_TRACE_LIMIT ? stack.substring(0, STACK_TRACE_LIMIT) + ' ...' : stack; | ||
} | ||
@@ -91,5 +89,3 @@ _shortenData(data) { | ||
const stringifiedData = typeof data === 'object' ? JSON.stringify(data) : data; | ||
return stringifiedData.length > DATA_LIMIT ? | ||
stringifiedData.substring(0, DATA_LIMIT) + ' ...' : | ||
stringifiedData; | ||
return stringifiedData.length > DATA_LIMIT ? stringifiedData.substring(0, DATA_LIMIT) + ' ...' : stringifiedData; | ||
} | ||
@@ -104,3 +100,3 @@ _getErrorDetails(error) { | ||
error_message: error.message, | ||
error_data: this._shortenData(error.data) | ||
error_data: this._shortenData(error.data), | ||
}; | ||
@@ -118,3 +114,3 @@ return Object.assign(baseDetails, this._getAxiosErrorDetails(error)); | ||
response_status_text: error.response ? error.response.statusText : undefined, | ||
response_data: error.response ? this._shortenData(error.response.data) : undefined | ||
response_data: error.response ? this._shortenData(error.response.data) : undefined, | ||
}; | ||
@@ -127,3 +123,3 @@ } | ||
output: console_1.consoleOutput, | ||
transformers: [] | ||
transformers: [], | ||
}; |
@@ -1,1 +0,1 @@ | ||
export declare function consoleOutput(formattedLog: unknown): void; | ||
export declare const consoleOutput: (formattedLog: unknown) => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.consoleOutput = void 0; | ||
function consoleOutput(formattedLog) { | ||
const consoleOutput = (formattedLog) => { | ||
console.log(formattedLog); | ||
} | ||
}; | ||
exports.consoleOutput = consoleOutput; |
@@ -6,5 +6,6 @@ { | ||
"scripts": { | ||
"test": "mocha --require ts-node/register ./src --recursive", | ||
"test:watch": "mocha --require ts-node/register ./src --recursive --watch", | ||
"lint": "eslint ./src/**/*.{ts,js}", | ||
"test": "mocha --require ts-node/register --extension ts ./src --recursive", | ||
"test:watch": "mocha --require ts-node/register --extension ts ./src --recursive --watch", | ||
"lint": "eslint ./src/**/*.ts", | ||
"lint:fix": "eslint ./src/**/*.ts --fix", | ||
"build": "rm -rf dist && tsc --project ./tsconfig.json", | ||
@@ -29,12 +30,22 @@ "release": "CI=true semantic-release", | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/node": "18.7.14", | ||
"@typescript-eslint/parser": "5.36.1", | ||
"@types/chai": "4.3.3", | ||
"@types/mocha": "10.0.0", | ||
"@types/node": "18.7.23", | ||
"@types/sinon": "10.0.13", | ||
"@types/sinon-chai": "3.2.8", | ||
"@typescript-eslint/eslint-plugin": "5.38.1", | ||
"@typescript-eslint/parser": "5.38.1", | ||
"axios": "0.27.2", | ||
"chai": "4.3.6", | ||
"eslint": "8.23.0", | ||
"eslint": "8.24.0", | ||
"eslint-config-emarsys": "5.1.0", | ||
"eslint-config-prettier": "8.5.0", | ||
"eslint-plugin-no-only-tests": "3.0.0", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"eslint-plugin-security": "1.5.0", | ||
"install": "0.13.0", | ||
"mocha": "10.0.0", | ||
"npm": "8.19.2", | ||
"prettier": "2.7.1", | ||
"semantic-release": "19.0.5", | ||
@@ -44,3 +55,3 @@ "sinon": "14.0.0", | ||
"ts-node": "10.9.1", | ||
"typescript": "4.8.3" | ||
"typescript": "4.8.4" | ||
}, | ||
@@ -55,3 +66,3 @@ "repository": { | ||
"homepage": "https://github.com/emartech/json-logger-js#readme", | ||
"version": "7.1.0" | ||
"version": "7.2.0" | ||
} |
@@ -13,2 +13,3 @@ # @emartech/json-logger | ||
### Usage | ||
@@ -15,0 +16,0 @@ |
{ | ||
"exclude": ["dist", "node_modules", "src/**/*.js"], | ||
"include": ["src/**/*.ts", "src/**/*.js"], | ||
"exclude": ["dist", "node_modules"], | ||
"include": ["src/**/*.ts"], | ||
"compilerOptions": { | ||
@@ -44,3 +44,3 @@ /* Visit https://aka.ms/tsconfig to read more about this file */ | ||
/* JavaScript Support */ | ||
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ | ||
"allowJs": false, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ | ||
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ | ||
@@ -47,0 +47,0 @@ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ |
40637
234
24
483