-
Notifications
You must be signed in to change notification settings - Fork 47
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
FileWriter Filename #34
Comments
I wrote my ideas and thoughts here, please take a look, comments and feedback are welcome. |
Ok, I understand. How about only rotate when conditions are meet. I have just tried using Finally I have been testing on Windows since most of out users use Windows. Our servers are on Linux, can't (can not) control what users prefer... |
Have tested on Windows.
Don't know if it needs to be Hard or Soft but maybe we can check if Program is on Windows && Admin and create a Hard or Soft? |
I remember |
Should we add a note on Readme about being admin on Windows or check if os is |
Okay, please let me have a try to fix symlink on windows... |
I don't think it's possible without being an admin. You can only do hard. tester-windows: mklink
Creates a symbolic link.
MKLINK [[/D] | [/H] | [/J]] Link Target
/D Creates a directory symbolic link. Default is a file
symbolic link.
/H Creates a hard link instead of a symbolic link.
/J Creates a Directory Junction.
Link Specifies the new symbolic link name.
Target Specifies the path (relative or absolute) that the new link
refers to.
tester-windows: mklink soft.log plog.2021-06-12.log
You do not have sufficient privilege to perform this operation.
tester-windows: mklink /H soft.log plog.2021-06-12.log
Hardlink created for soft.log <<===>> plog.2021-06-12.log |
Yes, I also found that. I will add a note to README, thanks! |
Thanks! |
How about this, when the name is the same, the MaxSize is not respected. |
I can add a "fix" to respect the diff --git a/file.go b/file.go
index 6f9b2f7..7427585 100644
--- a/file.go
+++ b/file.go
@@ -223,6 +223,9 @@ func (w *FileWriter) create() (err error) {
return err
}
w.size = 0
+ if st, err := w.file.Stat(); err == nil {
+ w.size = st.Size()
+ }
os.Remove(w.Filename)
if !w.ProcessID { But the problem is, when the rotation happens, it will not create a new file, because of In that case, may you also need specifies the // Cleaner specifies an optional cleanup function of log backups after rotation,
// if not set, the default behavior is to delete more than MaxBackups log files.
Cleaner func(filename string, maxBackups int, matches []os.FileInfo) to rename the original file to |
Thanks! |
This could be considered as an improvement? maybe?
When you output to file, you have
name.timestamp.ext
that's ok... but when there are many cases when this is a little bit unconfutable.I think I should be
name.ext
and when rotatedname.timestamp.ext
When rotation happens, because of whatever condition, having timestamp is ok, but if there are no conditions that have been meet it should be just the name and append data.
For compatibility issues we could implement an
AutoRotateOnInitialize (bool)
, orOnlyTimestampOnRotate (bool)
a simpler name...The text was updated successfully, but these errors were encountered: