-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrotate_lumberjack_windows.go
40 lines (35 loc) · 1.15 KB
/
rotate_lumberjack_windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Package rotate provides a rolling logger.
//
// Note that this is v2.0 of rotate, and should be imported using gopkg.in
// thusly:
//
// import "gopkg.in/natefinch/rotate.v2"
//
// The package name remains simply rotate, and the code resides at
// https://github.com/natefinch/rotate under the v2.0 branch.
//
// rotate is intended to be one part of a logging infrastructure.
// It is not an all-in-one solution, but instead is a pluggable
// component at the bottom of the logging stack that simply controls the files
// to which logs are written.
//
// rotate plays well with any logging package that can write to an
// io.Writer, including the standard library's log package.
//
// rotate assumes that only one process is writing to the output files.
// Using the same rotate configuration from multiple processes on the same
// machine will result in improper behavior.
// +build windows
package logrotate
import (
"os"
"syscall"
"time"
)
func createTime(file *os.File) (time.Time, error) {
fi, err := file.Stat()
if err != nil {
return time.Now(), err
}
return time.Unix(0, fi.Sys().(*syscall.Win32FileAttributeData).CreationTime.Nanoseconds()), nil
}