-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Net 3181 consul gh issue 15709 allow log file naming like nomad - fix…
… bug (#18631) * fixes file name for consul * added log file * added tests for rename method * append instead of trunc * fix file truncate issue * added changelog * fix for build destros ci * removed changelog * solaris
- Loading branch information
1 parent
78e3cbe
commit 13eefbb
Showing
5 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//go:build darwin || freebsd || netbsd || openbsd | ||
// +build darwin freebsd netbsd openbsd | ||
|
||
package logging | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func (l *LogFile) createTime(stat os.FileInfo) time.Time { | ||
stat_t := stat.Sys().(*syscall.Stat_t) | ||
createTime := stat_t.Ctimespec | ||
return time.Unix(int64(createTime.Sec), int64(createTime.Nsec)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//go:build dragonfly || linux | ||
// +build dragonfly linux | ||
|
||
package logging | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func (l *LogFile) createTime(stat os.FileInfo) time.Time { | ||
stat_t := stat.Sys().(*syscall.Stat_t) | ||
createTime := stat_t.Ctim | ||
// Sec and Nsec are int32 in 32-bit architectures. | ||
return time.Unix(int64(createTime.Sec), int64(createTime.Nsec)) //nolint:unconvert | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//go:build solaris | ||
// +build solaris | ||
|
||
package logging | ||
|
||
import ( | ||
"os" | ||
"syscall" | ||
"time" | ||
) | ||
|
||
func (l *LogFile) createTime(stat os.FileInfo) time.Time { | ||
stat_t := stat.Sys().(*syscall.Stat_t) | ||
createTime := stat_t.Ctim | ||
// Sec and Nsec are int32 in 32-bit architectures. | ||
return time.Unix(int64(createTime.Sec), int64(createTime.Nsec)) //nolint:unconvert | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package logging | ||
|
||
import ( | ||
"os" | ||
"time" | ||
) | ||
|
||
func (l *LogFile) createTime(stat os.FileInfo) time.Time { | ||
// Use `ModTime` as an approximation if the exact create time is not | ||
// available. | ||
// On Windows, the file create time is not updated after the active log | ||
// rotates, so use `ModTime` as an approximation as well. | ||
return stat.ModTime() | ||
} |