diff --git a/package.json b/package.json index a1414f7..cf86a12 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "coveralls:push": "cat ./coverage/lcov.info | coveralls", "jest": "BABEL_ENV=test NODE_ENV=test jest --no-cache -w 1 --detectOpenHandles --config jest.config.json", "flow": "flow", - "flow:coverage": "flow-coverage-report -i 'packages/**/src/main/**/*.js' -t html -t json -t text --threshold 90", + "flow:coverage": "flow-coverage-report -i 'packages/**/src/main/**/*.js' -t html -t json -t text --threshold 85", "flow:fetch": "flow-typed install lodash-es@4.17.10", "lint": "standard packages/**/src/**/*.js packages/**/test/**/*.js", "lint:fix": "yarn lint --fix", diff --git a/packages/logwrap-core/src/main/js/logwrap.js b/packages/logwrap-core/src/main/js/logwrap.js index 69bf9eb..ae4553d 100644 --- a/packages/logwrap-core/src/main/js/logwrap.js +++ b/packages/logwrap-core/src/main/js/logwrap.js @@ -56,16 +56,17 @@ export default class Logwrap implements ILogwrap { } static initLogMethod (method: ILogLevel, level: ILogLevel, pipeline: INormalizedPipeline): ILogMethod { - return (...args: IAny): void => this.perform(level, method, pipeline, args) + return (...args: IAny): void => { + const entry = this.normalizeEntry(method, args, {}) + return this.perform(level, pipeline, entry) + } } - static perform (treshold: ILogLevel, level: ILogLevel, pipeline: INormalizedPipeline, input: IAny[]): IAny { - if (!this.validateLevel(treshold, level)) { + static perform (treshold: ILogLevel, pipeline: INormalizedPipeline, entry: ILogEntry): IAny { + if (!this.validateLevel(treshold, entry.level)) { return } - const entry = this.normalizeEntry(level, input, {}) - return reduce( pipeline, (memo, pipe) => pipe(memo) || memo, diff --git a/packages/logwrap-core/src/test/js/logwrap.js b/packages/logwrap-core/src/test/js/logwrap.js index 46f8f3a..3bc38fa 100644 --- a/packages/logwrap-core/src/test/js/logwrap.js +++ b/packages/logwrap-core/src/test/js/logwrap.js @@ -128,11 +128,15 @@ describe('logwrap-core/logwrap', () => { const input = ['foo', 'bar'] it('does nothing on log level mismatch', () => { - expect(perform('error', 'warn')).toBeUndefined() + const entry = normalizeEntry('warn', input, {}) + + expect(perform('error', pipeline, entry)).toBeUndefined() }) it('processes data though the pipeline', () => { - expect(perform('debug', 'warn', pipeline, input)).toEqual({ + const entry = normalizeEntry('warn', input, {}) + + expect(perform('debug', pipeline, entry)).toEqual({ level: 'warn', input, meta: {} diff --git a/yarn.lock b/yarn.lock index f93a846..a80e775 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1814,13 +1814,6 @@ once "^1.4.0" universal-user-agent "^4.0.0" -"@qiwi/logwrap-core@^1.4.2": - version "1.4.2" - resolved "https://registry.yarnpkg.com/@qiwi/logwrap-core/-/logwrap-core-1.4.2.tgz#90d819bbb98758687ce2771da9440c032a2b0964" - integrity sha512-ZLThJ4VKacxUlitxF6+Ic0fDKj3mlX6P8uOknaIzhy4vccBzbkl9/hq71dMR6wd+36DDMYWbT8TKxVDlVKlZug== - dependencies: - lodash-es "^4.17.15" - "@qiwi/substrate-types@^1.0.0": version "1.16.0" resolved "https://registry.yarnpkg.com/@qiwi/substrate-types/-/substrate-types-1.16.0.tgz#3f7e54a8e12bd4f8a7aefd9b563842f38adf0ad1"