Skip to content

Commit

Permalink
Merge pull request #266: MaintenanceVerb: use "_service" instead of t…
Browse files Browse the repository at this point in the history
…imestamp

The service overloads the logs dir by running maintenance verbs in
the background. Change the name to use "service" instead of
a timestamp when the log is started by the service.

This will cause the log files to grow, as we append to the logs
every time.

Resolves #177.
  • Loading branch information
derrickstolee authored Dec 20, 2019
2 parents 3eb4282 + e4711be commit 5946d89
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Scalar.Common/Enlistment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static string GetNewLogFileName(
logsRoot,
name + ".log");

if (fileSystem.FileExists(fullPath))
if (string.IsNullOrEmpty(logId) && fileSystem.FileExists(fullPath))
{
fullPath = Path.Combine(
logsRoot,
Expand Down
2 changes: 1 addition & 1 deletion Scalar.Common/ScalarEnlistment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public static string GetNewScalarLogFileName(
return Enlistment.GetNewLogFileName(
logsRoot,
"scalar_" + logFileType,
logId: null,
logId: logId,
fileSystem: fileSystem);
}

Expand Down
7 changes: 6 additions & 1 deletion Scalar/CommandLine/MaintenanceVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ protected override void Execute(ScalarEnlistment enlistment)
{
string cacheServerUrl = CacheServerResolver.GetUrlFromConfig(enlistment);

string logFileName = ScalarEnlistment.GetNewScalarLogFileName(
enlistment.ScalarLogsRoot,
ScalarConstants.LogFileTypes.Maintenance,
logId: this.StartedByService ? "service" : null);

tracer.AddLogFileEventListener(
ScalarEnlistment.GetNewScalarLogFileName(enlistment.ScalarLogsRoot, ScalarConstants.LogFileTypes.Maintenance),
logFileName,
EventLevel.Informational,
Keywords.Any);
tracer.WriteStartEvent(
Expand Down

0 comments on commit 5946d89

Please sign in to comment.