Skip to content

Commit

Permalink
reduce logging a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed Apr 16, 2024
1 parent 588fb5f commit 432d74c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 29 deletions.
3 changes: 0 additions & 3 deletions uSync.BackOffice/Services/SyncFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,6 @@ public XElement LoadXElement(string file)
/// </summary>
public void SaveFile(string filename, Stream stream)
{
logger.LogDebug("Saving File: {file}", filename);

using (Stream fileStream = OpenWrite(filename))
{
stream.CopyTo(fileStream);
Expand All @@ -280,7 +278,6 @@ public void SaveFile(string filename, Stream stream)
public void SaveFile(string filename, string content)
{
var localFile = GetAbsPath(filename);
logger.LogDebug("Saving File: {local} [{length}]", localFile, content.Length);

using (Stream stream = OpenWrite(localFile))
{
Expand Down
6 changes: 1 addition & 5 deletions uSync.BackOffice/Services/uSyncService_Handlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ public IEnumerable<uSyncAction> ImportHandler(string handlerAlias, uSyncImportOp

if (handlerPair == null) return Enumerable.Empty<uSyncAction>();
var folders = GetHandlerFolders(options.Folders, handlerPair.Handler);

_logger.LogDebug("> Import Handler {handler}", handlerAlias);


using var scope = _scopeProvider.CreateNotificationScope(
eventAggregator: _eventAggregator,
loggerFactory: _loggerFactory,
Expand All @@ -64,8 +62,6 @@ public IEnumerable<uSyncAction> ImportHandler(string handlerAlias, uSyncImportOp
options.Callbacks?.Update);

var results = handlerPair.Handler.ImportAll(folders, handlerPair.Settings, options);

_logger.LogDebug("< Import Handler {handler}", handlerAlias);

scope.Complete();

Expand Down
9 changes: 0 additions & 9 deletions uSync.BackOffice/SyncHandlers/SyncHandlerRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,6 @@ public IEnumerable<uSyncAction> ImportAll(string folder, HandlerSettings config,
/// </remarks>
public IEnumerable<uSyncAction> ImportAll(string[] folders, HandlerSettings config, uSyncImportOptions options)
{
logger.LogDebug("ImportAll: {handlerType} STARTING", handlerType);

var cacheKey = PrepCaches();
runtimeCache.ClearByKey(cacheKey);

Expand All @@ -282,8 +280,6 @@ public IEnumerable<uSyncAction> ImportAll(string[] folders, HandlerSettings conf
int count = 0;
int total = items.Count;

logger.LogDebug("ImportAll: {handlerType} {count} items", handlerType, total);

foreach (var item in items)
{
count++;
Expand Down Expand Up @@ -322,17 +318,14 @@ public IEnumerable<uSyncAction> ImportAll(string[] folders, HandlerSettings conf
serializer.Save(updates.Select(x => x.Item));
}

logger.LogDebug("ImportAll: Second Pass: {handlerType} {updates}", handlerType, updates.Count);
PerformSecondPassImports(updates, actions, config, options.Callbacks?.Update);
}

if (actions.All(x => x.Success) && cleanMarkers.Count > 0)
{
logger.LogDebug("ImportAll: Clean: {handlerType} {cleans}", handlerType, cleanMarkers.Count);
PerformImportClean(cleanMarkers, actions, config, options.Callbacks?.Update);
}

logger.LogDebug("ImportAll: {handlerType} DONE", handlerType);
CleanCaches(cacheKey);
options.Callbacks?.Update?.Invoke("Done", 3, 3);

Expand Down Expand Up @@ -541,8 +534,6 @@ virtual public IEnumerable<uSyncAction> ImportElement(XElement node, string file
var serializerOptions = new SyncSerializerOptions(options.Flags, settings.Settings, options.UserId);
serializerOptions.MergeSettings(options.Settings);

logger.LogDebug("ImportElement: {alias} {path} {filename}", node.GetAlias(), node.GetPath(), shortFilename);

// get the item.
var attempt = DeserializeItem(node, serializerOptions);
var action = uSyncActionHelper<TObject>.SetAction(attempt, GetNameFromFileOrNode(shortFilename, node), node.GetKey(), this.Alias, IsTwoPass);
Expand Down
15 changes: 3 additions & 12 deletions uSync.Core/Serialization/SyncSerializerRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,8 @@ protected SyncAttempt<TObject> ProcessAction(XElement node, SyncSerializerOption

var actionType = node.Attribute("Change").ValueOrDefault<SyncActionType>(SyncActionType.None);


var (key, alias) = FindKeyAndAlias(node);

logger.LogDebug("Empty Node : Processing Action {actionType} ({key} {alias})", actionType, key, alias);

switch (actionType)
{
case SyncActionType.Delete:
Expand All @@ -186,19 +183,17 @@ protected SyncAttempt<TObject> ProcessAction(XElement node, SyncSerializerOption

protected virtual SyncAttempt<TObject> ProcessDelete(Guid key, string alias, SerializerFlags flags)
{
logger.LogDebug("Processing Delete {0} {1}", key, alias);

var item = this.FindItem(key);
if (item == null && !string.IsNullOrWhiteSpace(alias))
{
// we need to build in some awareness of alias matching in the folder
// because if someone deletes something in one place and creates it
// somewhere else the alias will exist, so we don't want to delete
// it from over there - this needs to be done at save time
// (bascially if a create happens) - turn any delete files into renames
// (basically if a create happens) - turn any delete files into renames

// A Tree Based serializer will return null if you ask it to find
// an item soley by alias, so this means we are only deleting by key
// an item solely by alias, so this means we are only deleting by key
// on tree's (e.g media, content)
item = this.FindItem(alias);
}
Expand All @@ -210,13 +205,11 @@ protected virtual SyncAttempt<TObject> ProcessDelete(Guid key, string alias, Ser
return SyncAttempt<TObject>.Succeed(alias, ChangeType.Delete);
}

logger.LogDebug("Delete Item not found");
return SyncAttempt<TObject>.Succeed(alias, ChangeType.NoChange);
}

protected virtual SyncAttempt<TObject> ProcessRename(Guid key, string alias, SerializerFlags flags)
{
logger.LogDebug("Process Rename (no action)");
return SyncAttempt<TObject>.Succeed(alias, ChangeType.NoChange);
}

Expand Down Expand Up @@ -287,8 +280,6 @@ private ChangeType CalculateEmptyChange(XElement node, XElement current)

public virtual SyncAttempt<XElement> SerializeEmpty(TObject item, SyncActionType change, string alias)
{
logger.LogDebug("Base: Serializing Empty Element {alias} {change}", alias, change);

if (string.IsNullOrEmpty(alias))
alias = ItemAlias(item);

Expand All @@ -305,7 +296,7 @@ private string MakeHash(XElement node)

using (MemoryStream s = new MemoryStream())
{
// for consistancy across platforms we need to harmonize line endings.
// for consistency across platforms we need to harmonize line endings.
using (var writer = XmlWriter.Create(s, new XmlWriterSettings { NewLineChars = "\r\n" }))
{
node.Save(writer);
Expand Down

0 comments on commit 432d74c

Please sign in to comment.