-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add option to set the binary mode of the log device #33
Add option to set the binary mode of the log device #33
Conversation
Does changing defaults to binmode break any backward compatibilities? For example, what if a log file is already written with previous version of loggers? If there are potential risks breaking backward compatibilities, I prefer adding another option. |
Let's summon @nobu for this kind of quiz. |
It seems there is no backward incompatibility between the two implementation. Both creating a file using binmode and appending to it without binmode and, creating a file without binmode and appending to it with binmode work fine.
|
This looks good, the only question I'd ask is should we change the mode of the file if it's supplied by the user? |
I think that should be up to the user. They should be able to pass a file using any mode they want. |
Okay one last point - do you want to update the documentation too so users know what's going on? |
Yeah, that one I believe we should. I'll take a look. |
Done |
0061b3b
to
496c69e
Compare
LGTM, but I'll let @sonots merge it. |
As far as I know, on windows, |
Also, someone may rely on encoding conversion feature of the text mode like writing source codes and log texts in EUC-JP and outputting logs with EUC-JP on Linux and Shift_JIS on windows using the text mode feature. (although I believe recent Japanese uses only UTF-8 on both environment). |
I agree the preference making defaults to |
I don't see any failure in your |
496c69e
to
9e69caa
Compare
Decided. Could you provide a new option like |
test/logger/test_logdevice.rb
Outdated
str = "\x80" | ||
str.force_encoding("ASCII-8BIT") | ||
logdev.write(str) | ||
logfile = File.open(@filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logfile
is left open.
Use File.binread
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Of course. Working on it. |
Without binmode strings with incompatible encoding can't be written in the file. This is very common in applications that log user provided parameters. We need to allow changing the binnary mode because right now it is impossible to use the built-in log rotation feature when you provide a File object to the LogDevice, and if you provide a filename you can't have binmode.
9e69caa
to
9114b3a
Compare
Changed this to take an option and kept the default as it was. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to be late. LGTM
Thank you! |
This was a great example of everyone working together and understanding each others requirements. Thanks for being great software engineers and human beings! |
Without binmode strings with incompatible encoding can't be written in
the file. This is very common in applications that log user provided
parameters.
We need to allow changing the binnary mode because right now it is impossible to use
the built-in log rotation feature when you provide a File object to the
LogDevice, and if you provide a filename you can't have binmode.