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

LoggerInitializer updated to create directory when it doesn't exists. #1130

Closed
wants to merge 1 commit into from
Closed

LoggerInitializer updated to create directory when it doesn't exists. #1130

wants to merge 1 commit into from

Conversation

bmpandrade
Copy link

The intent of this change is to allow fluentd to create a directory that is passed by --log and don't exists on the system.

Cheers

@@ -268,7 +268,8 @@ def initialize(path, level, chuser, chgroup, opts)

def init
if @path && @path != "-"
@io = File.open(@path, "a")
Dir.mkdir(File.dirname(@path)) unless File.exists?(@path)
Copy link
Member

Choose a reason for hiding this comment

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

It fails when the file (@path) doesn't exist and directory (File.dirname(@path)) already exists, and when the parent directories of directory (File.dirname(File.dirname(@path))) doesn't exist.
It's better to use FileUtils.mkdir_p(File.dirname(@path)) unless Dir.exist?(File.dirname(@path))

Copy link
Member

Choose a reason for hiding this comment

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

File.exists? (and Dir.exists?) are deprecated methods. Use File.exist? instead.

@tagomoris
Copy link
Member

Please check tests and CI results.

@bmpandrade
Copy link
Author

Thanks @tagomoris for the feedback. I'll give it a look and make the proper updates 👍

@tagomoris tagomoris added v0.14 moreinfo Missing version, need reproducible steps, need to investigate more labels Aug 10, 2016
@tagomoris
Copy link
Member

@bmandrade ping?

@bmpandrade
Copy link
Author

Sorry @tagomoris , I'll try to take on this as soon as possible

@ganmacs
Copy link
Member

ganmacs commented Dec 12, 2019

closed by #2732

@ganmacs ganmacs closed this Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moreinfo Missing version, need reproducible steps, need to investigate more v0.14
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants