@@ -38,9 +38,15 @@ const (
3838 maxRedirects = 10
3939 jobTimeout = 5 * time .Minute
4040 // File permissions
41- directoryPermissions = 0777
41+ directoryPermissions = 0o777
4242 // Stage constants
4343 mainStage = "Main"
44+ // Log prefix constants
45+ debugPrefix = "##[debug]"
46+ warnPrefix = "##[warn]"
47+ errorPrefix = "##[error]"
48+ panicPrefix = "##[panic]"
49+ fatalPrefix = "##[fatal]"
4450)
4551
4652type ghaFormatter struct {
@@ -54,11 +60,14 @@ type ghaFormatter struct {
5460}
5561
5662func flushInternal (rec * protocol.TimelineRecord , res * model.StepResult ) {
57- if res .Conclusion == model .StepStatusSuccess {
63+ switch res .Conclusion {
64+ case model .StepStatusSuccess :
5865 rec .Complete ("Succeeded" )
59- } else if res . Conclusion == model .StepStatusSkipped {
66+ case model .StepStatusSkipped :
6067 rec .Complete ("Skipped" )
61- } else {
68+ case model .StepStatusFailure :
69+ rec .Complete ("Failed" )
70+ default :
6271 rec .Complete ("Failed" )
6372 }
6473}
@@ -176,12 +185,21 @@ func (f *ghaFormatter) Format(entry *logrus.Entry) ([]byte, error) {
176185 }
177186
178187 prefix := entry .Time .UTC ().Format (protocol .TimestampOutputFormat ) + " "
179- if entry .Level == logrus .DebugLevel {
180- prefix += "##[debug]"
181- } else if entry .Level == logrus .WarnLevel {
182- prefix += "##[warning]"
183- } else if entry .Level == logrus .ErrorLevel {
184- prefix += "##[error]"
188+ switch entry .Level {
189+ case logrus .DebugLevel :
190+ prefix += debugPrefix
191+ case logrus .WarnLevel :
192+ prefix += warnPrefix
193+ case logrus .ErrorLevel :
194+ prefix += errorPrefix
195+ case logrus .PanicLevel :
196+ prefix += panicPrefix
197+ case logrus .FatalLevel :
198+ prefix += fatalPrefix
199+ case logrus .InfoLevel :
200+ // No special prefix for info level
201+ case logrus .TraceLevel :
202+ prefix += debugPrefix
185203 }
186204 entry .Message = f .linefeedregex .ReplaceAllString (prefix + strings .Trim (entry .Message , "\r \n " ), "\n " + prefix )
187205
@@ -639,7 +657,7 @@ func downloadAndExtractAction(
639657 if contextLogger != nil {
640658 contextLogger .Infof ("Downloading action %v/%v (sha:%v) from %v" , owner , name , resolvedSha , tarURL )
641659 }
642- req , err := http .NewRequestWithContext (ctx , "GET" , tarURL , http .NoBody )
660+ req , err := http .NewRequestWithContext (ctx , http . MethodGet , tarURL , http .NoBody )
643661 if err != nil {
644662 return err
645663 }
0 commit comments