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

Merging logs written to the syslog for text-format #1018

Merged
merged 1 commit into from Apr 17, 2023

Conversation

raj-prince
Copy link
Collaborator

@raj-prince raj-prince commented Mar 21, 2023

Description

When gcsfuse writes the logs to syslog in text-format. We were getting multiple lines for a single logs, due to multiple calls of writer inside text-writer method.

But this issue was not happening in case of writing logs to a log-file. Here is the reason, why it was not happening in case of file-writer:-

// Output writes the output for a logging event. The string s contains
// the text to print after the prefix specified by the flags of the
// Logger. A newline is appended if the last character of s is not
// already a newline. Calldepth is the count of the number of
// frames to skip when computing the file name and line number
// if Llongfile or Lshortfile is set; a value of 1 will print the details
// for the caller of Output.
func Output(calldepth int, s string) error {
	return std.Output(calldepth+1, s) // +1 for this frame.
}

file-name - google-golang/src/log/log.go

To write any types of logs, we use this output method, which implicitly add '\n` character in the last.

Logs before this change:

2023-03-20T15:41:15.245221+05:30 33princer.hyd.corp.google.com gcsfuse[2489872]: I
2023-03-20T15:41:15.245390+05:30 33princer.hyd.corp.google.com gcsfuse[2489872]: 0320 15:41:15.245131
2023-03-20T15:41:15.245564+05:30 33princer.hyd.corp.google.com gcsfuse[2489872]:  
2023-03-20T15:41:15.245737+05:30 33princer.hyd.corp.google.com gcsfuse[2489872]: Error while mounting gcsfuse: mountWithConn: Mount: mount: running /usr/bin/fusermount3: exit status 1

Logs after this change:

2023-03-21T09:56:51.475043+05:30 33princer.hyd.corp.google.com gcsfuse[2854760]: I0321 09:56:51.474998 Creating a mount at "/usr/local/google/home/princer/Downloads/mnt"
2023-03-21T09:56:51.476144+05:30 33princer.hyd.corp.google.com gcsfuse[2854760]: I0321 09:56:51.476085 Creating a new server...
2023-03-21T09:56:51.476235+05:30 33princer.hyd.corp.google.com gcsfuse[2854760]: I0321 09:56:51.476131 Set up root directory for bucket princer-working-dirs
2023-03-21T09:56:51.476285+05:30 33princer.hyd.corp.google.com gcsfuse[2854760]: D0321 09:56:51.476173 gcs: Req              0x0: <- ListObjects("")
2023-03-21T09:56:52.330972+05:30 33princer.hyd.corp.google.com gcsfuse[2854760]: D0321 09:56:52.330789 gcs: Req              0x0: -> ListObjects("") (854.59719ms): OK
2023-03-21T09:56:52.331347+05:30 33princer.hyd.corp.google.com gcsfuse[2854760]: I0321 09:56:52.330902 Mounting file system "princer-working-dirs"...
2023-03-21T09:56:52.335218+05:30 33princer.hyd.corp.google.com gcsfuse[2854760]: I0321 09:56:52.335035 Error while mounting gcsfuse: mountWithConn: Mount: mount: running /usr/bin/fusermount3: exit status 1

Testing

  1. Manual
    Checked the logs in file with this change:
321 09:48:11.461464 Opening GCS connection...
I0321 09:48:11.462350 Creating a mount at "/usr/local/google/home/princer/Downloads/mnt"
I0321 09:48:11.463601 Creating a new server...
I0321 09:48:11.463641 Set up root directory for bucket princer-working-dirs
D0321 09:48:11.463670 gcs: Req              0x0: <- ListObjects("")
D0321 09:48:12.753526 gcs: Req              0x0: -> ListObjects("") (1.289840961s): OK
I0321 09:48:12.753641 Mounting file system "princer-working-dirs"...
I0321 09:48:12.757755 Error while mounting gcsfuse: mountWithConn: Mount: mount: running /usr/bin/fusermount3: exit status 1

Copy link
Collaborator

@sethiay sethiay left a comment

Choose a reason for hiding this comment

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

Can we write in PR description that this change is specifically to fix logging in case of syslog and also that it didn't break logging in case of log file ?

@raj-prince
Copy link
Collaborator Author

Can we write in PR description that this change is specifically to fix logging in case of syslog and also that it didn't break logging in case of log file ?

Done.

@raj-prince raj-prince requested a review from sethiay April 17, 2023 11:09
@raj-prince raj-prince merged commit 487c607 into master Apr 17, 2023
3 checks passed
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.

None yet

2 participants