Skip to content
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

Merged
merged 10 commits into from
Nov 1, 2024

Conversation

SheepSheepChen
Copy link
Collaborator

No description provided.

@SheepSheepChen SheepSheepChen merged commit 475ad2b into TencentBlueKing:builder-stack Nov 1, 2024
3 checks passed
return logType
}
return ""
}
Copy link
Collaborator

@narasux narasux Nov 1, 2024

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 ""
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

稍稍优化下,可读性会更好,目前的写法没有重点,且重复代码太多了,看着累人

Copy link
Collaborator

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)可能会更好?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好,我下个 pr 一起修改

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants