Skip to content

Logger refactor: log message polishing - #12

Merged
EmilianoSanchez merged 13 commits into
logger_refactor_baselinefrom
logger_polishing_log_messages
Mar 25, 2021
Merged

Logger refactor: log message polishing#12
EmilianoSanchez merged 13 commits into
logger_refactor_baselinefrom
logger_polishing_log_messages

Conversation

@EmilianoSanchez

@EmilianoSanchez EmilianoSanchez commented Mar 19, 2021

Copy link
Copy Markdown
Contributor

Javascript commons library

What did you accomplish?

  • Changes:
    • reuse messages for input validation, in favor of size reduction.
    • updated log message to follow the format: '[LOGLEVEL] splitio => optionalPrefixOrCategory: message'
    • replaced 'Factory instantiation' category to 'settings' category for split filter validator logs, like the other settings validators (except API Key validation logs).
    • removed 'Retrieving SDK client.' to reuse 'Retrieving default SDK client.'

How do we test the changes introduced in this PR?

Extra Notes

import { ILogger } from '../../logger/types';
import sanitizeValue from './sanitize';
import { DEBUG_24, WARN_1, WARN_0 } from '../../logger/constants';
import { DEBUG_24, WARN_ENGINE_NO_ATTRIBUTES, WARN_ENGINE_INVALID_VALUE } from '../../logger/constants';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR: Let's use this format instead of a numeric one. It's clearer!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in next commit

Comment thread src/listeners/node.ts Outdated
import { DEBUG_28, DEBUG_29, DEBUG_30, ERROR_1 } from '../logger/constants';
import { CLEANUP_LB, DEBUG_26, DEBUG_27 } from '../logger/constants';

const LOG_EXTRA = 'for SIGTERM signal.';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When polishing, try to find a more descriptive name.

Comment thread src/listeners/node.ts Outdated

stop() {
this.settings.log.debug(DEBUG_29);
this.settings.log.debug(DEBUG_27, [LOG_EXTRA]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this file, the logs have a different format, but all of them have something appended at the end. Not necessary now, but eventually we should try and be consistent if possible.

Comment thread src/logger/constants.ts
@@ -1,151 +1,140 @@
// commons

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-order the messages in the file pls.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be done in a coming commit, when renaming constants

Comment thread src/logger/index.ts
const formattedText = this._generateLogMessage(level, text);
if (typeof msg === 'number') {
const format = this.codes.get(msg);
if (format) msg = sprintf(format, args);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this should run for string messages too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! good idea. It was added in next PR

Comment thread src/logger/messages/error.ts Outdated

export const codesError: [number, string][] = [
// evaluator
[ERROR_0, ENGINE_COMBINER_LB + 'Invalid Split provided, no valid conditions found'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's rephrase to: "Invalid Split, no valid rules found"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@EmilianoSanchez EmilianoSanchez changed the title Logger refactor: log message polishing [WIP] Logger refactor: log message polishing Mar 25, 2021
@EmilianoSanchez
EmilianoSanchez merged commit 7d2d1f1 into logger_refactor_baseline Mar 25, 2021
@EmilianoSanchez
EmilianoSanchez deleted the logger_polishing_log_messages branch May 20, 2022 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants