66 "strings"
77
88 "github.com/actions-oss/act-cli/pkg/common"
9+ "github.com/sirupsen/logrus"
910)
1011
1112var commandPatternGA * regexp.Regexp
@@ -41,11 +42,12 @@ func (rc *RunContext) commandHandler(ctx context.Context) common.LineHandler {
4142 }
4243
4344 if resumeCommand != "" && command != resumeCommand {
44- logger .Infof (" \U00002699 %s" , line )
45+ logger .WithFields (logrus. Fields { "command" : "ignored" , "raw" : line }). Infof (" \U00002699 %s" , line )
4546 return false
4647 }
4748 arg = unescapeCommandData (arg )
4849 kvPairs = unescapeKvPairs (kvPairs )
50+ defCommandLogger := logger .WithFields (logrus.Fields {"command" : command , "kvPairs" : kvPairs , "arg" : arg , "raw" : line })
4951 switch command {
5052 case "set-env" :
5153 rc .setEnv (ctx , kvPairs , arg )
@@ -54,27 +56,27 @@ func (rc *RunContext) commandHandler(ctx context.Context) common.LineHandler {
5456 case "add-path" :
5557 rc .addPath (ctx , arg )
5658 case "debug" :
57- logger .Debugf (" \U0001F4AC %s" , line )
59+ defCommandLogger .Debugf (" \U0001F4AC %s" , line )
5860 case "warning" :
59- logger .Warnf (" \U0001F6A7 %s" , line )
61+ defCommandLogger .Warnf (" \U0001F6A7 %s" , line )
6062 case "error" :
61- logger .Errorf (" \U00002757 %s" , line )
63+ defCommandLogger .Errorf (" \U00002757 %s" , line )
6264 case "add-mask" :
6365 rc .AddMask (arg )
64- logger .Infof (" \U00002699 %s" , "***" )
66+ defCommandLogger .Infof (" \U00002699 %s" , "***" )
6567 case "stop-commands" :
6668 resumeCommand = arg
67- logger .Infof (" \U00002699 %s" , line )
69+ defCommandLogger .Infof (" \U00002699 %s" , line )
6870 case resumeCommand :
6971 resumeCommand = ""
70- logger .Infof (" \U00002699 %s" , line )
72+ defCommandLogger .Infof (" \U00002699 %s" , line )
7173 case "save-state" :
72- logger .Infof (" \U0001f4be %s" , line )
74+ defCommandLogger .Infof (" \U0001f4be %s" , line )
7375 rc .saveState (ctx , kvPairs , arg )
7476 case "add-matcher" :
75- logger .Infof (" \U00002753 add-matcher %s" , arg )
77+ defCommandLogger .Infof (" \U00002753 add-matcher %s" , arg )
7678 default :
77- logger .Infof (" \U00002753 %s" , line )
79+ defCommandLogger .Infof (" \U00002753 %s" , line )
7880 }
7981
8082 return false
@@ -83,7 +85,7 @@ func (rc *RunContext) commandHandler(ctx context.Context) common.LineHandler {
8385
8486func (rc * RunContext ) setEnv (ctx context.Context , kvPairs map [string ]string , arg string ) {
8587 name := kvPairs ["name" ]
86- common .Logger (ctx ).Infof (" \U00002699 ::set-env:: %s=%s" , name , arg )
88+ common .Logger (ctx ).WithFields (logrus. Fields { "command" : "set-env" , "name" : name , "arg" : arg }). Infof (" \U00002699 ::set-env:: %s=%s" , name , arg )
8789 if rc .Env == nil {
8890 rc .Env = make (map [string ]string )
8991 }
@@ -115,11 +117,11 @@ func (rc *RunContext) setOutput(ctx context.Context, kvPairs map[string]string,
115117 return
116118 }
117119
118- logger .Infof (" \U00002699 ::set-output:: %s=%s" , outputName , arg )
120+ logger .WithFields (logrus. Fields { "command" : "set-output" , "name" : outputName , "arg" : arg }). Infof (" \U00002699 ::set-output:: %s=%s" , outputName , arg )
119121 result .Outputs [outputName ] = arg
120122}
121123func (rc * RunContext ) addPath (ctx context.Context , arg string ) {
122- common .Logger (ctx ).Infof (" \U00002699 ::add-path:: %s" , arg )
124+ common .Logger (ctx ).WithFields (logrus. Fields { "command" : "add-path" , "arg" : arg }). Infof (" \U00002699 ::add-path:: %s" , arg )
123125 extraPath := []string {arg }
124126 for _ , v := range rc .ExtraPath {
125127 if v != arg {
0 commit comments