mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
Improve logging for PT Run (#6800)
* init code pass * adjusting tabbing for readabilty * few small adjustments
This commit is contained in:
@@ -44,7 +44,8 @@ namespace Wox.Infrastructure.Storage
|
||||
if (File.Exists(FilePath))
|
||||
{
|
||||
File.Delete(FilePath);
|
||||
Log.Info($"|BinaryStorage.TryLoad|Deleting cached data at <{FilePath}>");
|
||||
|
||||
Log.Info($"Deleting cached data at <{FilePath}>", GetType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +53,8 @@ namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
if (new FileInfo(FilePath).Length == 0)
|
||||
{
|
||||
Log.Error($"|BinaryStorage.TryLoad|Zero length cache file <{FilePath}>");
|
||||
Log.Error($"Zero length cache file <{FilePath}>", GetType());
|
||||
|
||||
Save(defaultData);
|
||||
return defaultData;
|
||||
}
|
||||
@@ -65,7 +67,8 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Info("|BinaryStorage.TryLoad|Cache file not exist, load default data");
|
||||
Log.Info("Cache file not exist, load default data", GetType());
|
||||
|
||||
Save(defaultData);
|
||||
return defaultData;
|
||||
}
|
||||
@@ -87,7 +90,8 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Log.Exception($"|BinaryStorage.Deserialize|Deserialize error for file <{FilePath}>", e);
|
||||
Log.Exception($"Deserialize error for file <{FilePath}>", e, GetType());
|
||||
|
||||
return defaultData;
|
||||
}
|
||||
finally
|
||||
@@ -128,12 +132,12 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
catch (SerializationException e)
|
||||
{
|
||||
Log.Exception($"|BinaryStorage.Save|serialize error for file <{FilePath}>", e);
|
||||
Log.Exception($"Serialize error for file <{FilePath}>", e, GetType());
|
||||
}
|
||||
}
|
||||
|
||||
_storageHelper.Close();
|
||||
Log.Info($"|BinaryStorage.Save|Saving cached data at <{FilePath}>");
|
||||
Log.Info($"Saving cached data at <{FilePath}>", GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Wox.Infrastructure.Storage
|
||||
if (File.Exists(FilePath))
|
||||
{
|
||||
File.Delete(FilePath);
|
||||
Log.Info($"|JsonStorage.TryLoad|Deleting cached data at <{FilePath}>");
|
||||
Log.Info($"Deleting cached data at <{FilePath}>", GetType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Wox.Infrastructure.Storage
|
||||
catch (JsonException e)
|
||||
{
|
||||
LoadDefault();
|
||||
Log.Exception($"|JsonStorage.Deserialize|Deserialize error for json <{FilePath}>", e);
|
||||
Log.Exception($"Deserialize error for json <{FilePath}>", e, GetType());
|
||||
}
|
||||
|
||||
if (_data == null)
|
||||
@@ -123,11 +123,12 @@ namespace Wox.Infrastructure.Storage
|
||||
string serialized = JsonConvert.SerializeObject(_data, Formatting.Indented);
|
||||
File.WriteAllText(FilePath, serialized);
|
||||
_storageHelper.Close();
|
||||
Log.Info($"|JsonStorage.Save|Saving cached data at <{FilePath}>");
|
||||
|
||||
Log.Info($"Saving cached data at <{FilePath}>", GetType());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Log.Error($"|JsonStorage.Save|Error in saving data at <{FilePath}>", e.Message);
|
||||
Log.Exception($"Error in saving data at <{FilePath}>", e, GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Wox.Infrastructure.Storage
|
||||
}
|
||||
catch (ArgumentException e)
|
||||
{
|
||||
Log.Info($"|LisRepository.Set| Trying to insert a duplicate item", e.Message);
|
||||
Log.Info($"Trying to insert a duplicate item {e.Message}", GetType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
if (!_items.TryAdd(insertedItem.GetHashCode(), insertedItem))
|
||||
{
|
||||
Log.Error($"|ListRepository.Add| Item Already Exists <{insertedItem}>");
|
||||
Log.Error($"Item Already Exists <{insertedItem}>", GetType());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Wox.Infrastructure.Storage
|
||||
{
|
||||
if (!_items.TryRemove(removedItem.GetHashCode(), out _))
|
||||
{
|
||||
Log.Error($"|ListRepository.Remove| Item Not Found <{removedItem}>");
|
||||
Log.Error($"Item Not Found <{removedItem}>", GetType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user