Browse Source

Log

pull/881/head
Sebastian 4 years ago
parent
commit
5176dc266a
  1. 14
      backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs
  2. 43
      backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/TemplateCommandMiddleware.cs

14
backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs

@ -15,21 +15,13 @@ namespace Squidex.Domain.Apps.Entities.Apps.Templates
public sealed class StringLogger : ILogger, ILogLine public sealed class StringLogger : ILogger, ILogLine
{ {
private const int MaxActionLength = 40; private const int MaxActionLength = 40;
private readonly ISemanticLog log;
private readonly string template;
private readonly List<string> lines = new List<string>(); private readonly List<string> lines = new List<string>();
private readonly List<string> errors = new List<string>(); private readonly List<string> errors = new List<string>();
private string startedLine = string.Empty; private string startedLine = string.Empty;
public bool CanWriteToSameLine => false; public bool CanWriteToSameLine => false;
public StringLogger(string template, ISemanticLog log) public void Flush(ISemanticLog log, string template)
{
this.template = template;
this.log = log;
}
public void Dispose()
{ {
var mesage = string.Join('\n', lines); var mesage = string.Join('\n', lines);
@ -50,6 +42,10 @@ namespace Squidex.Domain.Apps.Entities.Apps.Templates
} }
} }
public void Dispose()
{
}
public void StepStart(string message) public void StepStart(string message)
{ {
if (message.Length > MaxActionLength - 3) if (message.Length > MaxActionLength - 3)

43
backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/TemplateCommandMiddleware.cs

@ -71,27 +71,34 @@ namespace Squidex.Domain.Apps.Entities.Apps.Templates
return; return;
} }
using (var cliLog = new StringLogger(template, log)) using (var cliLog = new StringLogger())
{ {
var session = CreateSession(app); try
var syncService = await CreateSyncServiceAsync(repository, session);
var syncOptions = new SyncOptions();
var targets = new ISynchronizer[]
{ {
new AppSynchronizer(cliLog), var session = CreateSession(app);
new AssetFoldersSynchronizer(cliLog),
new AssetsSynchronizer(cliLog), var syncService = await CreateSyncServiceAsync(repository, session);
new RulesSynchronizer(cliLog), var syncOptions = new SyncOptions();
new SchemasSynchronizer(cliLog),
new WorkflowsSynchronizer(cliLog), var targets = new ISynchronizer[]
new ContentsSynchronizer(cliLog) {
}; new AppSynchronizer(cliLog),
new AssetFoldersSynchronizer(cliLog),
foreach (var target in targets) new AssetsSynchronizer(cliLog),
new RulesSynchronizer(cliLog),
new SchemasSynchronizer(cliLog),
new WorkflowsSynchronizer(cliLog),
new ContentsSynchronizer(cliLog)
};
foreach (var target in targets)
{
await target.ImportAsync(syncService, syncOptions, session);
}
}
finally
{ {
await target.ImportAsync(syncService, syncOptions, session); cliLog.Flush(log, template);
} }
} }
} }

Loading…
Cancel
Save