func (rl *RotateLogs) GenFilename() (string, error) {
	now := CurrentTime()
	diff := time.Duration(now.Add(rl.Offset).UnixNano()) % rl.RotationTime
	t := now.Add(time.Duration(-1 * diff))
	str, err := strftime.Format(rl.LogFile, t)
	if err != nil {
		return "", err
	}
	return str, err
}
Пример #2
0
func strftime() (string, error) {
	var err error
	now := time.Now()
	path := strings.Replace(*logFile, "%s", fmt.Sprint(now.Unix()), -1)
	path = strings.Replace(path, "%h", hostname, -1)
	path, err = _strftime.Format(path, now)
	if err != nil {
		return "", err
	}
	return path, nil
}