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

Output timestamp #207

Closed
mm-matthias opened this issue Aug 22, 2023 · 7 comments
Closed

Output timestamp #207

mm-matthias opened this issue Aug 22, 2023 · 7 comments

Comments

@mm-matthias
Copy link

Is it possible to output the timestamp for every command? This would help debugging some random errors I get in my CI pipelines. I'm writing the logs to files.

So far I've tried:

installLogsCollector({
  enableContinuousLogging: false,  // a value of 'true' leads to no logs being written to file at all
  processLog: (args: Log) => {
    const [type, message, severity] = args;
    return [type, `${new Date().toISOString()}\n${message}`, severity];
  },
});

But the output shows the same timestamp (completely equal including milliseconds) for every single output line. This seems to be the timestamp after the test is done and all logs are written. This value is not of much use to debug my timeouts.

Is it possible to get the timestamp of a message at the instant when it's being logged?

@archfz
Copy link
Owner

archfz commented Aug 31, 2023

I have looked into this. It is a nice idea.

For this I would propose a new configuration on support side: commandTimings: null | 'timestamp'. Once enabled we would add additional property to logs created with current date on support side. On printer side we would detect logs having this new property, and I am thinking that we would print this just above the log line.

When null we would prevent adding this property to not affect performance.

Currently our logs are described by the interface [type, message severity] However this interface is not ideal, since extending it with additional properties is making the code harder to read. I would propose with this feature to introduce a breaking change and change this interface from array type to object type.

Changes will have to be done mainly in LogCollectorState to use the new type and to add the date metadata when config is enabled. Type for options which receive logs will also need to be updated. Contribution is welcome.

@mm-matthias
Copy link
Author

@archfz Thanks for analyzing this and making a proposal for the implementation! Your description sounds quite much like what I had in mind (including the array to object refactoring).

I was also wondering if one could add timestamps for requests and responses to spot any timeouts caused by slow server-side processing.

As for actual implementation I'll see what I can do, but I don't make any promises.

@AlexGuironnetRTE
Copy link
Contributor

Hello!
I would love this feature as well! We're tracking a particularly elusive bug on our CI and a timestamp would help match console logs to backend logs. I've never worked on a plugin so I don't think I can help much with the implementation but if you need people to test it let me know!

Also, many thanks for this plugin, it has really gotten us out of some really tricky debugging ;-)

@archfz
Copy link
Owner

archfz commented Feb 7, 2024

Released in 6.0.0

@archfz archfz closed this as completed Feb 7, 2024
AlexGuironnetRTE added a commit to AlexGuironnetRTE/cypress-terminal-report that referenced this issue Feb 12, 2024
AlexGuironnetRTE added a commit to AlexGuironnetRTE/cypress-terminal-report that referenced this issue Feb 12, 2024
@AlexGuironnetRTE
Copy link
Contributor

AlexGuironnetRTE commented Feb 12, 2024

Thank you so much for adding this feature and releasing it so quickly! It's really helping!
At first I wondered why I was seeing the timestamp in the terminal output but not in the files, but that's because we're using the txt output. So I tried my hand at adding it the timestamp to the txt output : #236
But then I realized that maybe you didn't add it to the txt output on purpose, so if that's the case no worries we'll just use json!
Thanks again !

@archfz
Copy link
Owner

archfz commented Feb 16, 2024

@AlexGuironnetRTE I forgot about logging it there as well. If you make the necessary changes on the PR you have made I will release that as well.

AlexGuironnetRTE added a commit to AlexGuironnetRTE/cypress-terminal-report that referenced this issue Feb 21, 2024
AlexGuironnetRTE added a commit to AlexGuironnetRTE/cypress-terminal-report that referenced this issue Feb 21, 2024
AlexGuironnetRTE added a commit to AlexGuironnetRTE/cypress-terminal-report that referenced this issue Feb 21, 2024
archfz added a commit that referenced this issue Feb 24, 2024
@AlexGuironnetRTE
Copy link
Contributor

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants