mirror of https://github.com/hashicorp/consul
Browse Source
* 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 * solarisspatel/fix-typo
Ashesh Vidyut
1 year ago
committed by
GitHub
5 changed files with 73 additions and 4 deletions
@ -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)) |
||||
} |
@ -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
|
||||
} |
@ -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
|
||||
} |
@ -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() |
||||
} |
Loading…
Reference in new issue