@@ -12,115 +12,127 @@ public static class ScriptHostServiceLoggerExtension
12
12
13
13
private static readonly Action < ILogger , Exception > _scriptHostServiceInitCanceledByRuntime =
14
14
LoggerMessage . Define (
15
- LogLevel . Information ,
16
- new EventId ( 500 , nameof ( ScriptHostServiceInitCanceledByRuntime ) ) ,
17
- "Initialization cancellation requested by runtime." ) ;
15
+ LogLevel . Information ,
16
+ new EventId ( 500 , nameof ( ScriptHostServiceInitCanceledByRuntime ) ) ,
17
+ "Initialization cancellation requested by runtime." ) ;
18
18
19
19
private static readonly Action < ILogger , int , TimeSpan , Exception > _unehealthyCountExceeded =
20
20
LoggerMessage . Define < int , TimeSpan > (
21
- LogLevel . Error ,
22
- new EventId ( 501 , nameof ( UnhealthyCountExceeded ) ) ,
23
- "Host unhealthy count exceeds the threshold of {healthCheckThreshold} for time window {healthCheckWindow}. Initiating shutdown." ) ;
21
+ LogLevel . Error ,
22
+ new EventId ( 501 , nameof ( UnhealthyCountExceeded ) ) ,
23
+ "Host unhealthy count exceeds the threshold of {healthCheckThreshold} for time window {healthCheckWindow}. Initiating shutdown." ) ;
24
24
25
25
private static readonly Action < ILogger , Exception > _offline =
26
26
LoggerMessage . Define (
27
- LogLevel . Information ,
28
- new EventId ( 502 , nameof ( Offline ) ) ,
29
- "Host is offline." ) ;
27
+ LogLevel . Information ,
28
+ new EventId ( 502 , nameof ( Offline ) ) ,
29
+ "Host is offline." ) ;
30
30
31
31
private static readonly Action < ILogger , Exception > _initializing =
32
32
LoggerMessage . Define (
33
- LogLevel . Information ,
34
- new EventId ( 503 , nameof ( Initializing ) ) ,
35
- "Initializing Host." ) ;
33
+ LogLevel . Information ,
34
+ new EventId ( 503 , nameof ( Initializing ) ) ,
35
+ "Initializing Host." ) ;
36
36
37
37
private static readonly Action < ILogger , int , int , Exception > _initialization =
38
38
LoggerMessage . Define < int , int > (
39
- LogLevel . Information ,
40
- new EventId ( 504 , nameof ( Initialization ) ) ,
41
- "Host initialization: ConsecutiveErrors={attemptCount}, StartupCount={startCount}" ) ;
39
+ LogLevel . Information ,
40
+ new EventId ( 504 , nameof ( Initialization ) ) ,
41
+ "Host initialization: ConsecutiveErrors={attemptCount}, StartupCount={startCount}" ) ;
42
42
43
43
private static readonly Action < ILogger , Exception > _inStandByMode =
44
44
LoggerMessage . Define (
45
- LogLevel . Information ,
46
- new EventId ( 505 , nameof ( InStandByMode ) ) ,
47
- "Host is in standby mode" ) ;
45
+ LogLevel . Information ,
46
+ new EventId ( 505 , nameof ( InStandByMode ) ) ,
47
+ "Host is in standby mode" ) ;
48
48
49
49
private static readonly Action < ILogger , Exception > _unhealthyRestart =
50
50
LoggerMessage . Define (
51
- LogLevel . Error ,
52
- new EventId ( 506 , nameof ( UnhealthyRestart ) ) ,
53
- "Host is unhealthy. Initiating a restart." ) ;
51
+ LogLevel . Error ,
52
+ new EventId ( 506 , nameof ( UnhealthyRestart ) ) ,
53
+ "Host is unhealthy. Initiating a restart." ) ;
54
54
55
55
private static readonly Action < ILogger , Exception > _stopping =
56
56
LoggerMessage . Define (
57
- LogLevel . Information ,
58
- new EventId ( 507 , nameof ( Stopping ) ) ,
59
- "Stopping host..." ) ;
57
+ LogLevel . Information ,
58
+ new EventId ( 507 , nameof ( Stopping ) ) ,
59
+ "Stopping host..." ) ;
60
60
61
61
private static readonly Action < ILogger , Exception > _didNotShutDown =
62
62
LoggerMessage . Define (
63
- LogLevel . Warning ,
64
- new EventId ( 508 , nameof ( DidNotShutDown ) ) ,
65
- "Host did not shutdown within its allotted time." ) ;
63
+ LogLevel . Warning ,
64
+ new EventId ( 508 , nameof ( DidNotShutDown ) ) ,
65
+ "Host did not shutdown within its allotted time." ) ;
66
66
67
- private static readonly Action < ILogger , Exception > _shutDownCompleted =
67
+ private static readonly Action < ILogger , Exception > _shutDownCompleted =
68
68
LoggerMessage . Define (
69
- LogLevel . Information ,
70
- new EventId ( 509 , nameof ( ShutDownCompleted ) ) ,
71
- "Host shutdown completed." ) ;
69
+ LogLevel . Information ,
70
+ new EventId ( 509 , nameof ( ShutDownCompleted ) ) ,
71
+ "Host shutdown completed." ) ;
72
72
73
73
private static readonly Action < ILogger , string , Exception > _skipRestart =
74
74
LoggerMessage . Define < string > (
75
- LogLevel . Debug ,
76
- new EventId ( 510 , nameof ( SkipRestart ) ) ,
77
- "Host restart was requested, but current host state is '{state}'. Skipping restart." ) ;
75
+ LogLevel . Debug ,
76
+ new EventId ( 510 , nameof ( SkipRestart ) ) ,
77
+ "Host restart was requested, but current host state is '{state}'. Skipping restart." ) ;
78
78
79
79
private static readonly Action < ILogger , Exception > _restarting =
80
80
LoggerMessage . Define (
81
- LogLevel . Information ,
82
- new EventId ( 511 , nameof ( Restarting ) ) ,
83
- "Restarting host." ) ;
81
+ LogLevel . Information ,
82
+ new EventId ( 511 , nameof ( Restarting ) ) ,
83
+ "Restarting host." ) ;
84
84
85
85
private static readonly Action < ILogger , Exception > _restarted =
86
86
LoggerMessage . Define (
87
- LogLevel . Information ,
88
- new EventId ( 512 , nameof ( Restarted ) ) ,
89
- "Host restarted." ) ;
87
+ LogLevel . Information ,
88
+ new EventId ( 512 , nameof ( Restarted ) ) ,
89
+ "Host restarted." ) ;
90
90
91
91
private static readonly Action < ILogger , string , string , Exception > _building =
92
92
LoggerMessage . Define < string , string > (
93
- LogLevel . Information ,
94
- new EventId ( 513 , nameof ( Building ) ) ,
95
- "Building host: startup suppressed:{skipHostStartup}, configuration suppressed: {skipHostJsonConfiguration}" ) ;
93
+ LogLevel . Information ,
94
+ new EventId ( 513 , nameof ( Building ) ) ,
95
+ "Building host: startup suppressed:{skipHostStartup}, configuration suppressed: {skipHostJsonConfiguration}" ) ;
96
96
97
97
private static readonly Action < ILogger , Exception > _startupWasCanceled =
98
98
LoggerMessage . Define (
99
- LogLevel . Debug ,
100
- new EventId ( 514 , nameof ( StartupWasCanceled ) ) ,
101
- "Host startup was canceled." ) ;
99
+ LogLevel . Debug ,
100
+ new EventId ( 514 , nameof ( StartupWasCanceled ) ) ,
101
+ "Host startup was canceled." ) ;
102
102
103
103
private static readonly Action < ILogger , Exception > _errorOccured =
104
104
LoggerMessage . Define (
105
- LogLevel . Debug ,
106
- new EventId ( 515 , nameof ( ErrorOccured ) ) ,
107
- "A host error has occurred" ) ;
105
+ LogLevel . Error ,
106
+ new EventId ( 515 , nameof ( ErrorOccured ) ) ,
107
+ "A host error has occurred" ) ;
108
108
109
109
private static readonly Action < ILogger , Exception > _errorOccuredInactive =
110
110
LoggerMessage . Define (
111
- LogLevel . Debug ,
112
- new EventId ( 516 , nameof ( ErrorOccuredInactive ) ) ,
113
- "A host error has occurred on an inactive host" ) ;
111
+ LogLevel . Warning ,
112
+ new EventId ( 516 , nameof ( ErrorOccuredInactive ) ) ,
113
+ "A host error has occurred on an inactive host" ) ;
114
114
115
115
private static readonly Action < ILogger , Exception > _cancellationRequested =
116
116
LoggerMessage . Define (
117
- LogLevel . Debug ,
118
- new EventId ( 517 , nameof ( CancellationRequested ) ) ,
119
- "Cancellation requested. A new host will not be started." ) ;
117
+ LogLevel . Debug ,
118
+ new EventId ( 517 , nameof ( CancellationRequested ) ) ,
119
+ "Cancellation requested. A new host will not be started." ) ;
120
+
121
+ private static readonly Action < ILogger , string , string , Exception > _activeHostChanging =
122
+ LoggerMessage . Define < string , string > (
123
+ LogLevel . Debug ,
124
+ new EventId ( 518 , nameof ( ActiveHostChanging ) ) ,
125
+ "Active host changing from '{oldHostInstanceId}' to '{newHostInstanceId}'." ) ;
126
+
127
+ private static readonly Action < ILogger , Exception > _enteringRestart =
128
+ LoggerMessage . Define (
129
+ LogLevel . Debug ,
130
+ new EventId ( 519 , nameof ( EnteringRestart ) ) ,
131
+ "Restart requested. Cancelling any active host startup." ) ;
120
132
121
133
public static void ScriptHostServiceInitCanceledByRuntime ( this ILogger logger )
122
134
{
123
- _scriptHostServiceInitCanceledByRuntime ( logger , null ) ;
135
+ _scriptHostServiceInitCanceledByRuntime ( logger , null ) ;
124
136
}
125
137
126
138
public static void UnhealthyCountExceeded ( this ILogger logger , int healthCheckThreshold , TimeSpan healthCheckWindow )
@@ -130,22 +142,22 @@ public static void UnhealthyCountExceeded(this ILogger logger, int healthCheckTh
130
142
131
143
public static void Offline ( this ILogger logger )
132
144
{
133
- _offline ( logger , null ) ;
145
+ _offline ( logger , null ) ;
134
146
}
135
147
136
148
public static void Initializing ( this ILogger logger )
137
149
{
138
- _initializing ( logger , null ) ;
150
+ _initializing ( logger , null ) ;
139
151
}
140
152
141
153
public static void Initialization ( this ILogger logger , int attemptCount , int startCount )
142
154
{
143
- _initialization ( logger , attemptCount , startCount , null ) ;
155
+ _initialization ( logger , attemptCount , startCount , null ) ;
144
156
}
145
157
146
158
public static void InStandByMode ( this ILogger logger )
147
159
{
148
- _inStandByMode ( logger , null ) ;
160
+ _inStandByMode ( logger , null ) ;
149
161
}
150
162
151
163
public static void UnhealthyRestart ( this ILogger logger )
@@ -155,7 +167,7 @@ public static void UnhealthyRestart(this ILogger logger)
155
167
156
168
public static void Stopping ( this ILogger logger )
157
169
{
158
- _stopping ( logger , null ) ;
170
+ _stopping ( logger , null ) ;
159
171
}
160
172
161
173
public static void DidNotShutDown ( this ILogger logger )
@@ -165,7 +177,7 @@ public static void DidNotShutDown(this ILogger logger)
165
177
166
178
public static void ShutDownCompleted ( this ILogger logger )
167
179
{
168
- _shutDownCompleted ( logger , null ) ;
180
+ _shutDownCompleted ( logger , null ) ;
169
181
}
170
182
171
183
public static void SkipRestart ( this ILogger logger , string state )
@@ -175,17 +187,17 @@ public static void SkipRestart(this ILogger logger, string state)
175
187
176
188
public static void Restarting ( this ILogger logger )
177
189
{
178
- _restarting ( logger , null ) ;
190
+ _restarting ( logger , null ) ;
179
191
}
180
192
181
193
public static void Restarted ( this ILogger logger )
182
194
{
183
- _restarted ( logger , null ) ;
195
+ _restarted ( logger , null ) ;
184
196
}
185
197
186
198
public static void Building ( this ILogger logger , string skipHostStartup , string skipHostJsonConfiguration )
187
199
{
188
- _building ( logger , skipHostStartup , skipHostJsonConfiguration , null ) ;
200
+ _building ( logger , skipHostStartup , skipHostJsonConfiguration , null ) ;
189
201
}
190
202
191
203
public static void StartupWasCanceled ( this ILogger logger )
@@ -207,5 +219,15 @@ public static void CancellationRequested(this ILogger logger)
207
219
{
208
220
_cancellationRequested ( logger , null ) ;
209
221
}
222
+
223
+ public static void ActiveHostChanging ( this ILogger logger , string oldHostInstanceId , string newHostInstanceId )
224
+ {
225
+ _activeHostChanging ( logger , oldHostInstanceId , newHostInstanceId , null ) ;
226
+ }
227
+
228
+ public static void EnteringRestart ( this ILogger logger )
229
+ {
230
+ _enteringRestart ( logger , null ) ;
231
+ }
210
232
}
211
233
}
0 commit comments