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

Timestamp is not in order #36

Closed
kaiduanx opened this issue Jul 16, 2020 · 6 comments
Closed

Timestamp is not in order #36

kaiduanx opened this issue Jul 16, 2020 · 6 comments

Comments

@kaiduanx
Copy link

The issue is that the timestamp is not in the right order. The time stamp of the log at 59 line is older than the timestamp of the log at 64 line. I only commented out the runBenMark() function.

~/NanoLog/sample$ ./decompressor decompress /tmp/logFile
2020-07-16 18:12:41.-00022964 main.cc:59 NOTICE[0]: A string, pointer, number, and float: 'Hello World', 0x7ffd9db8d8bc, 512, 3.141590
2020-07-16 18:12:41.-00022108 main.cc:64 NOTICE[0]: Shortend String: 'Hello World' and shortend float 3.14

Decompression Complete after printing 2 log messages

~/NanoLog/sample$ git diff
diff --git a/sample/main.cc b/sample/main.cc
index af67390..c4523cb 100644
--- a/sample/main.cc
+++ b/sample/main.cc
@@ -64,7 +64,7 @@ int main(int argc, char** argv) {
3.14159);

  • runBenchmark();
  • //runBenchmark();

    // Optional: Flush all pending log messages to disk
    NanoLog::sync();

@syang0
Copy link
Member

syang0 commented Jul 16, 2020

Hi kaiduanx,

I think the issue is related to #28 where log messages at the beginning of the file can sometimes have a negative nanosecond timestamp (notice the little dash character - after the decimal point). The timestamps are still in order; it's just that nanosecond count is printed out as a negative value. I suspect the fix may be just to add an if-condition in the decompressor to check for this case. However, I'm not able to reproduce the problem on my setup.

Could you send me your log file, so I can verify the fix?

Best Regards,
Stephen Yang

@kaiduanx
Copy link
Author

Please send an email to [email protected], I will send the file to you.

@syang0
Copy link
Member

syang0 commented Jul 16, 2020

Actually, can you post the file here? You can attach files to GitHub comments; simply drag the file into the text field.

Instructions: https://docs.github.com/en/github/managing-your-work-on-github/file-attachments-on-issues-and-pull-requests

Example File: ProofOfConcept.txt

@kaiduanx
Copy link
Author

logFile.log

syang0 added a commit that referenced this issue Jul 17, 2020
Previously, the decompressor would output negative timestamps when it
encountered a log message with a timestamp earlier than the conversion
time marked in the log file's checkpoint. This patch fixes this issue
by checking for this case and adjusting the output as necessary.
@syang0
Copy link
Member

syang0 commented Jul 17, 2020

Hey kaiduanx,

The problem should be fixed now. Give it a try and let me know if it works.

Best Regards,
Stephen Yang

@kaiduanx
Copy link
Author

@syang0 , the problem is fixed, please see the following log. Many thanks, @syang0

~/NanoLog/sample$ ./decompressor decompress /tmp/logFile
2020-07-17 09:34:53.999992889 main.cc:59 NOTICE[0]: A string, pointer, number, and float: 'Hello World', 0x7ffdf907d2dc, 512, 3.141590
2020-07-17 09:34:53.999993750 main.cc:64 NOTICE[0]: Shortend String: 'Hello World' and shortend float 3.14

Decompression Complete after printing 2 log messages

@syang0 syang0 closed this as completed Jul 20, 2020
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

No branches or pull requests

2 participants