-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 获取应用日志 #1691
feat: 获取应用日志 #1691
Conversation
cnb-builder-shim/internal/devsandbox/webserver/service/app_logs.go
Outdated
Show resolved
Hide resolved
cnb-builder-shim/internal/devsandbox/webserver/service/app_logs.go
Outdated
Show resolved
Hide resolved
cnb-builder-shim/internal/devsandbox/webserver/service/app_logs.go
Outdated
Show resolved
Hide resolved
...ilder-shim/internal/devsandbox/webserver/service/testdata/templates/helloworld/app_desc.yaml
Outdated
Show resolved
Hide resolved
cnb-builder-shim/internal/devsandbox/webserver/service/app_logs.go
Outdated
Show resolved
Hide resolved
cnb-builder-shim/internal/devsandbox/webserver/service/app_logs.go
Outdated
Show resolved
Hide resolved
cnb-builder-shim/internal/devsandbox/webserver/service/deploy_test.go
Outdated
Show resolved
Hide resolved
return logType | ||
} | ||
return "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func getLogType(info os.FileInfo) string {
if info.IsDir() {
return ""
}
filename := info.Name()
extName := filepath.Ext(filename)
// 使用文件名称小写格式作为日志类型
if extName == ".log" {
return strings.ToLower(strings.TrimSuffix(filename, extName))
}
return ""
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
稍稍优化下,可读性会更好,目前的写法没有重点,且重复代码太多了,看着累人
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw,在外面依赖 logType == "" 判断其实也不是好的实践,返回 (string,error)/(string,bool)可能会更好?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好,我下个 pr 一起修改
No description provided.