diff --git a/main.go b/main.go index 6c39640..0d52858 100644 --- a/main.go +++ b/main.go @@ -88,8 +88,8 @@ func ValidatePassword(pass string) bool { } func Process(logStruct LogStruct) error { - fileName := GetPath(true, logStruct.Time.Year(), logStruct.Time.Month(), logStruct.Time.Day(), logStruct.Time.Hour(), logStruct.Kubernetes.NamespaceName, logStruct.Stream, logStruct.Kubernetes.ContainerName) - path := GetPath(false, logStruct.Time.Year(), logStruct.Time.Month(), logStruct.Time.Day(), logStruct.Time.Hour(), logStruct.Kubernetes.NamespaceName, logStruct.Stream, logStruct.Kubernetes.ContainerName) + fileName := GetPath(true, logStruct.Time.Year(), logStruct.Time.Month(), logStruct.Time.Day(), logStruct.Kubernetes.NamespaceName, logStruct.Stream, logStruct.Kubernetes.ContainerName) + path := GetPath(false, logStruct.Time.Year(), logStruct.Time.Month(), logStruct.Time.Day(), logStruct.Kubernetes.NamespaceName, logStruct.Stream, logStruct.Kubernetes.ContainerName) // validate path exists if _, err := os.Stat(path); os.IsNotExist(err) { @@ -121,14 +121,14 @@ func Process(logStruct LogStruct) error { } -func GetPath(includeFileName bool, year int, month time.Month, day int, hour int, namespace string, stream string, containerName string) string { +func GetPath(includeFileName bool, year int, month time.Month, day int, namespace string, stream string, containerName string) string { // dir + year/month/day/namespace/hour/podName-stream.log // month to int monthNumber := int(month) if includeFileName { - return fmt.Sprintf("%s/%d-%d/%d/%s/%d/%s-%s.log", config.Dir.Dir, year, monthNumber, day, namespace, hour, containerName, stream) + return fmt.Sprintf("%s/%s/%d-%d/%d/%s-%s.log", config.Dir.Dir, namespace, year, monthNumber, day, containerName, stream) } - return fmt.Sprintf("%s/%d-%d/%d/%s/%d/", config.Dir.Dir, year, monthNumber, day, namespace, hour) + return fmt.Sprintf("%s/%s/%d-%d/%d/", config.Dir.Dir, namespace, year, monthNumber, day) }