Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply time prefix to plain (terminal) logs #3212

Merged
merged 2 commits into from
Feb 10, 2022
Merged

Conversation

d4vidi
Copy link
Collaborator

@d4vidi d4vidi commented Feb 8, 2022

Description

In this pull request, I have enabled a custom (short) timestamp prefix to terminal logs. Other log outputs should have remained intact.

Before:

detox[35368] INFO:  [test.js] DETOX_CONFIGURATION="android.emu.release" DETOX_LOGLEVEL="verbose" DETOX_REPORT_SPECS=true DETOX_START_TIMESTAMP=1644339539856 DETOX_USE_CUSTOM_LOGGER=true nyc jest --config e2e/config.js --testNamePattern '^((?!:ios:).)*$' e2e/01.sanity.test.js
detox[35370] DEBUG: [WSS_CREATE] Detox server listening on localhost:54581...
detox[35370] DEBUG: [WSS_CONNECTION, #54582] registered a new connection.
detox[35370] DEBUG: [EXEC_CMD, #0] "/Users/amitd/Library/Android/sdk/emulator/emulator" -list-avds --verbose
detox[35370] DEBUG: [EXEC_CMD, #1] "/Users/amitd/Library/Android/sdk/emulator/emulator" -version
detox[35370] DEBUG: [EMU_BIN_VERSION_DETECT] Detected emulator binary version { major: 30, minor: 5, patch: 4, toString: [Function: toString] }
detox[35370] DEBUG: [ALLOCATE_DEVICE] Trying to allocate a device based on "Pixel_3A_API_29"
detox[35370] DEBUG: [EXEC_CMD, #2] "/Users/amitd/Library/Android/sdk/platform-tools/adb"  devices
detox[35370] DEBUG: [EXEC_SUCCESS, #2] List of devices attached

After:

18:58:59.862 detox[35368] INFO:  [test.js] DETOX_CONFIGURATION="android.emu.release" DETOX_LOGLEVEL="verbose" DETOX_REPORT_SPECS=true DETOX_START_TIMESTAMP=1644339539856 DETOX_USE_CUSTOM_LOGGER=true nyc jest --config e2e/config.js --testNamePattern '^((?!:ios:).)*$' e2e/01.sanity.test.js
18:59:02.434 detox[35370] DEBUG: [WSS_CREATE] Detox server listening on localhost:54581...
18:59:02.446 detox[35370] DEBUG: [WSS_CONNECTION, #54582] registered a new connection.
18:59:02.561 detox[35370] DEBUG: [EXEC_CMD, #0] "/Users/amitd/Library/Android/sdk/emulator/emulator" -list-avds --verbose
18:59:02.593 detox[35370] DEBUG: [EXEC_CMD, #1] "/Users/amitd/Library/Android/sdk/emulator/emulator" -version
18:59:02.856 detox[35370] DEBUG: [EMU_BIN_VERSION_DETECT] Detected emulator binary version { major: 30, minor: 5, patch: 4, toString: [Function: toString] }
18:59:02.857 detox[35370] DEBUG: [ALLOCATE_DEVICE] Trying to allocate a device based on "Pixel_3A_API_29"
18:59:02.860 detox[35370] DEBUG: [EXEC_CMD, #2] "/Users/amitd/Library/Android/sdk/platform-tools/adb"  devices
18:59:02.876 detox[35370] DEBUG: [EXEC_SUCCESS, #2] List of devices attached

For features/enhancements:

  • I have added/updated the relevant references in the documentation files.

For API changes:

  • I have made the necessary changes in the types index file.

@d4vidi d4vidi requested a review from noomorph February 8, 2022 16:57
@d4vidi d4vidi self-assigned this Feb 8, 2022
@@ -11,6 +14,9 @@ const temporaryPath = require('../artifacts/utils/temporaryPath');
const argparse = require('./argparse');
const customConsoleLogger = require('./customConsoleLogger');

const LOG_DATE_FORMAT = "HH:MM:ss.l";
const shortDateFormatter = (date) => dateFormat(date, LOG_DATE_FORMAT);
Copy link
Collaborator

@noomorph noomorph Feb 9, 2022

Choose a reason for hiding this comment

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

Won't it be more efficient to:

date.toTimeString().split(' ')[0] + '.' + `${date.getMilliseconds()}`.padStart(3, '0')

instead of importing yet another package?

+"dateformat": "4.5.1",

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Definitely. I will do that 👍🏻

Copy link
Collaborator Author

@d4vidi d4vidi Feb 9, 2022

Choose a reason for hiding this comment

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

I was contemplating whether ןא would be better to have this for future usage. On 2nd thought, I'm inclined to say that since this hasn't troubled us this long, the odds of it being so are slim.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see what you mean. If we ever need more advanced date manipulation, we can add it later, no problem.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@noomorph I've taken a rather more verbose approach, that is nevertheless aligned with your suggestion. Please have a glance.

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.

Add timestamps to detox-log artifacts
2 participants