Skip to content

Commit 30ab611

Browse files
committed
Fix SecretManager log statements. Fixes #3834
1 parent 89b896c commit 30ab611

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/WebJobs.Script.WebHost/Security/SecretManager.cs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ public SecretManager(ISecretsRepository repository, IKeyValueConverterFactory ke
5252
GetHostSecretsAsync().GetAwaiter().GetResult();
5353
}
5454

55-
_traceWriter.Info(Resources.TraceSecretsRepo, repository.ToString());
56-
_logger?.LogInformation(Resources.TraceSecretsRepo, repository.ToString());
55+
string message = string.Format(Resources.TraceSecretsRepo, repository.ToString());
56+
_traceWriter.Info(message);
57+
_logger?.LogInformation(message);
5758
}
5859

5960
public void Dispose()
@@ -153,10 +154,9 @@ public async virtual Task<IDictionary<string, string>> GetFunctionSecretsAsync(s
153154
if (secrets == null)
154155
{
155156
// no secrets exist for this function so generate them
156-
string message = string.Format(Resources.TraceFunctionSecretGeneration, functionName);
157-
_traceWriter.Info(message, traceProperties);
158-
159-
_logger?.LogInformation(message);
157+
string messageGeneratoin = string.Format(Resources.TraceFunctionSecretGeneration, functionName);
158+
_traceWriter.Info(messageGeneratoin, traceProperties);
159+
_logger?.LogInformation(messageGeneratoin);
160160
secrets = new FunctionSecrets
161161
{
162162
Keys = new List<Key>
@@ -175,18 +175,18 @@ public async virtual Task<IDictionary<string, string>> GetFunctionSecretsAsync(s
175175
}
176176
catch (CryptographicException)
177177
{
178-
string message = string.Format(Resources.TraceNonDecryptedFunctionSecretRefresh, functionName);
179-
_traceWriter.Info(message, traceProperties);
180-
_logger?.LogInformation(message);
178+
string messageNonDecrypted = string.Format(Resources.TraceNonDecryptedFunctionSecretRefresh, functionName);
179+
_traceWriter.Info(messageNonDecrypted, traceProperties);
180+
_logger?.LogInformation(messageNonDecrypted);
181181
await PersistSecretsAsync(secrets, functionName, true);
182182
await RefreshSecretsAsync(secrets, functionName);
183183
}
184184

185185
if (secrets.HasStaleKeys)
186186
{
187-
string message = string.Format(Resources.TraceStaleFunctionSecretRefresh, functionName);
188-
_traceWriter.Info(message);
189-
_logger?.LogInformation(message);
187+
string messageStaleFunction = string.Format(Resources.TraceStaleFunctionSecretRefresh, functionName);
188+
_traceWriter.Info(messageStaleFunction);
189+
_logger?.LogInformation(messageStaleFunction);
190190
await RefreshSecretsAsync(secrets, functionName);
191191
}
192192

@@ -206,8 +206,9 @@ public async virtual Task<IDictionary<string, string>> GetFunctionSecretsAsync(s
206206
.ToDictionary(kv => kv.Key, kv => kv.Value);
207207
}
208208

209-
_traceWriter.Info(Resources.TraceFunctionsKeysLoaded, functionName);
210-
_logger?.LogInformation(Resources.TraceFunctionsKeysLoaded, functionName);
209+
string messageLoaded = string.Format(Resources.TraceFunctionsKeysLoaded, functionName);
210+
_traceWriter.Info(messageLoaded);
211+
_logger?.LogInformation(messageLoaded);
211212

212213
return functionSecrets;
213214
}

0 commit comments

Comments
 (0)