-
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.
Backport of Net 3181 consul gh issue 15709 allow log file naming like…
… nomad - fix bug into release/1.15.x (#18641) * backport of commit a5ad366 * backport of commit 24e7b9b * 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 * removed change log --------- Co-authored-by: absolutelightning <ashesh.vidyut@hashicorp.com> Co-authored-by: Ashesh Vidyut <134911583+absolutelightning@users.noreply.github.com>
- Loading branch information
1 parent
bfa612c
commit 6bdd979
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() | ||
} |