@@ -29,7 +29,7 @@ func logExecute(stateCtx *StateCtx, l *slog.Logger) {
29
29
l .Info ("engine: execute" , args ... )
30
30
}
31
31
32
- func logDo (execSessID int64 , cmd0 Command , l * slog.Logger ) {
32
+ func logDo (execSessID int64 , cmd0 Command , subCmd bool , l * slog.Logger ) {
33
33
var args []any
34
34
35
35
if execSessID > 0 {
@@ -38,22 +38,25 @@ func logDo(execSessID int64, cmd0 Command, l *slog.Logger) {
38
38
args = []any {"sess" , cmd0 .SessID ()}
39
39
}
40
40
41
+ cmdArg := "cmd"
42
+ if subCmd {
43
+ cmdArg = "sub_cmd"
44
+ }
45
+
41
46
switch cmd := cmd0 .(type ) {
42
47
case * CommitCommand :
43
- args = append (args , "cmd" , "commit" , "len" , len (cmd .Commands ))
48
+ args = append (args , cmdArg , "commit" , "len" , len (cmd .Commands ))
44
49
case * CommitStateCtxCommand :
45
- args = append (args , "cmd" , "commit_state_ctx" , "id" , cmd .StateCtx .Current .ID , "rev" , cmd .StateCtx .Current .Rev )
50
+ args = append (args , cmdArg , "commit_state_ctx" , "id" , cmd .StateCtx .Current .ID , "rev" , cmd .StateCtx .Current .Rev )
46
51
case * TransitCommand :
47
- args = append (args ,
48
- "cmd" , "transit" ,
49
- "id" , cmd .StateCtx .Current .ID ,
50
- "rev" , cmd .StateCtx .Current .Rev ,
51
- "to" , cmd .To ,
52
- "labels" , cmd .StateCtx .Current .Labels ,
53
- )
52
+ args = append (args , cmdArg , "transit" , "id" , cmd .StateCtx .Current .ID , "rev" , cmd .StateCtx .Current .Rev , "to" , cmd .To )
53
+
54
+ if len (cmd .StateCtx .Current .Labels ) > 0 {
55
+ args = append (args , "labels" , cmd .StateCtx .Current .Labels )
56
+ }
54
57
case * PauseCommand :
55
58
args = append (args ,
56
- "cmd" , "pause" ,
59
+ cmdArg , "pause" ,
57
60
"id" , cmd .StateCtx .Current .ID ,
58
61
"rev" , cmd .StateCtx .Current .Rev ,
59
62
)
@@ -63,43 +66,53 @@ func logDo(execSessID int64, cmd0 Command, l *slog.Logger) {
63
66
args = append (args , "labels" , cmd .StateCtx .Current .Labels )
64
67
case * ResumeCommand :
65
68
args = append (args ,
66
- "cmd" , "resume" ,
69
+ cmdArg , "resume" ,
67
70
"id" , cmd .StateCtx .Current .ID ,
68
71
"rev" , cmd .StateCtx .Current .Rev ,
69
- "labels" , cmd .StateCtx .Current .Labels ,
70
72
)
73
+ if len (cmd .StateCtx .Current .Labels ) > 0 {
74
+ args = append (args , "labels" , cmd .StateCtx .Current .Labels )
75
+ }
71
76
case * EndCommand :
72
77
args = append (args ,
73
- "cmd" , "end" ,
78
+ cmdArg , "end" ,
74
79
"id" , cmd .StateCtx .Current .ID ,
75
80
"rev" , cmd .StateCtx .Current .Rev ,
76
- "labels" , cmd .StateCtx .Current .Labels ,
77
81
)
82
+ if len (cmd .StateCtx .Current .Labels ) > 0 {
83
+ args = append (args , "labels" , cmd .StateCtx .Current .Labels )
84
+ }
78
85
case * DelayCommand :
79
86
args = append (args ,
80
- "cmd" , "delay" ,
87
+ cmdArg , "delay" ,
81
88
"id" , cmd .StateCtx .Current .ID ,
82
89
"rev" , cmd .StateCtx .Current .Rev ,
83
90
"execute_at" , cmd .ExecuteAt ,
84
- "labels" , cmd .StateCtx .Current .Labels ,
85
91
)
92
+ if len (cmd .StateCtx .Current .Labels ) > 0 {
93
+ args = append (args , "labels" , cmd .StateCtx .Current .Labels )
94
+ }
86
95
case * ExecuteCommand :
87
96
args = append (args ,
88
- "cmd" , "execute" ,
97
+ cmdArg , "execute" ,
89
98
"id" , cmd .StateCtx .Current .ID ,
90
99
"rev" , cmd .StateCtx .Current .Rev ,
91
- "labels" , cmd .StateCtx .Current .Labels ,
92
100
)
101
+ if len (cmd .StateCtx .Current .Labels ) > 0 {
102
+ args = append (args , "labels" , cmd .StateCtx .Current .Labels )
103
+ }
93
104
case * NoopCommand :
94
105
args = append (args ,
95
- "cmd" , "noop" ,
106
+ cmdArg , "noop" ,
96
107
"id" , cmd .StateCtx .Current .ID ,
97
108
"rev" , cmd .StateCtx .Current .Rev ,
98
- "labels" , cmd .StateCtx .Current .Labels ,
99
109
)
110
+ if len (cmd .StateCtx .Current .Labels ) > 0 {
111
+ args = append (args , "labels" , cmd .StateCtx .Current .Labels )
112
+ }
100
113
case * AttachDataCommand :
101
114
args = append (args ,
102
- "cmd" , "attach_data" ,
115
+ cmdArg , "attach_data" ,
103
116
"id" , cmd .StateCtx .Current .ID ,
104
117
"rev" , cmd .StateCtx .Current .Rev ,
105
118
"data_id" , cmd .Data .ID ,
@@ -108,28 +121,28 @@ func logDo(execSessID int64, cmd0 Command, l *slog.Logger) {
108
121
)
109
122
case * GetDataCommand :
110
123
args = append (args ,
111
- "cmd" , "get_data" ,
124
+ cmdArg , "get_data" ,
112
125
"id" , cmd .StateCtx .Current .ID ,
113
126
"rev" , cmd .StateCtx .Current .Rev ,
114
127
"data_id" , cmd .Data .ID ,
115
128
"data_rev" , cmd .Data .Rev ,
116
129
"alias" , cmd .Alias ,
117
130
)
118
131
case * UnstackCommand :
119
- args = append (args , "cmd" , "unstack" )
132
+ args = append (args , cmdArg , "unstack" )
120
133
case * StackCommand :
121
- args = append (args , "cmd" , "stack" )
134
+ args = append (args , cmdArg , "stack" )
122
135
case * GetStateByIDCommand :
123
- args = append (args , "cmd" , "get_state_by_id" ,
136
+ args = append (args , cmdArg , "get_state_by_id" ,
124
137
"id" , cmd .ID ,
125
138
"rev" , cmd .Rev ,
126
139
)
127
140
case * GetStateByLabelsCommand :
128
- args = append (args , "cmd" , "get_state_by_labels" ,
141
+ args = append (args , cmdArg , "get_state_by_labels" ,
129
142
"labels" , cmd .Labels ,
130
143
)
131
144
case * GetStatesCommand :
132
- args = append (args , "cmd" , "get_states" )
145
+ args = append (args , cmdArg , "get_states" )
133
146
if cmd .SinceRev > 0 {
134
147
args = append (args , "since_rev" , cmd .SinceRev )
135
148
}
@@ -146,13 +159,13 @@ func logDo(execSessID int64, cmd0 Command, l *slog.Logger) {
146
159
args = append (args , "limit" , cmd .Limit )
147
160
}
148
161
case * GetDelayedStatesCommand :
149
- args = append (args , "cmd" , "get_delayed_states" ,
162
+ args = append (args , cmdArg , "get_delayed_states" ,
150
163
"since" , cmd .Since ,
151
164
"until" , cmd .Until ,
152
165
"offset" , cmd .Offset ,
153
166
)
154
167
default :
155
- args = append (args , "cmd" , fmt .Sprintf ("%T" , cmd ))
168
+ args = append (args , cmdArg , fmt .Sprintf ("%T" , cmd ))
156
169
}
157
170
158
171
l .Info ("engine: do" , args ... )
0 commit comments