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

Rollbar pid files #938

Merged
merged 2 commits into from
Feb 5, 2020
Merged

Rollbar pid files #938

merged 2 commits into from
Feb 5, 2020

Conversation

Aristat
Copy link
Contributor

@Aristat Aristat commented Feb 4, 2020

Hi! We want to save the logs to different files for each puma workers, is it possible to add such a PR to the gem?

in addition:

  • small refactor old code
  • added functionality for rename processed files(for smooth file processing by our agent)

thanks!

@waltjones
Copy link
Contributor

@Aristat Thank you for the PR. Just a few questions.

do_write_item(item)
end
end

def do_write_item(item)
Copy link
Contributor

@waltjones waltjones Feb 4, 2020

Choose a reason for hiding this comment

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

Is there a reason other than style for the method rename write_item -> do_write_item?

Copy link
Contributor

Choose a reason for hiding this comment

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

I misread that. I see it now.

def do_write_item(item)
log_info '[Rollbar] Writing item to file'

body = item.dump
return unless body

file_name = if configuration.files_with_pid_name_enabled
configuration.filepath.gsub(EXTENSION_REGEXP, "_#{Process.pid}\\0")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not familiar with using the backslash zero in the filename here. Is this a convention?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, https://apidock.com/ruby/v2_6_3/String/gsub (see examples Replacing with "\" and match), it's just needed for replace file_name.rollbar to file_name_12345.rollbar
since in filepath includes extension and I have to do the replacement in this way(I specified that new flags only work if .rollbar is at the end, because it is hardcoded in a gem)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, it's a backreference for gsub. Thank you.

@waltjones waltjones merged commit 266d427 into rollbar:master Feb 5, 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

Successfully merging this pull request may close these issues.

2 participants