Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit a8ac83a

Browse files
committed
Log errors
1 parent e165776 commit a8ac83a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/GitHub.Logging/Logging/LogManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ static Logger CreateLogger()
2020

2121
return new LoggerConfiguration()
2222
.Enrich.WithThreadId()
23+
#if DEBUG
24+
.MinimumLevel.Debug()
25+
#else
2326
.MinimumLevel.Information()
27+
#endif
2428
.WriteTo.File(logPath,
2529
fileSizeLimitBytes: null,
2630
outputTemplate: outputTemplate)

src/GitHub.VisualStudio/Services/UsageService.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
using GitHub.Helpers;
99
using GitHub.Models;
1010
using Task = System.Threading.Tasks.Task;
11+
using GitHub.Logging;
12+
using Serilog;
1113

1214
namespace GitHub.Services
1315
{
1416
[Export(typeof(IUsageService))]
1517
public class UsageService : IUsageService
1618
{
19+
static readonly ILogger log = LogManager.ForContext<UsageService>();
1720
const string StoreFileName = "ghfvs.usage";
1821
static readonly Calendar cal = CultureInfo.InvariantCulture.Calendar;
1922
readonly IGitHubServiceProvider serviceProvider;
@@ -65,8 +68,9 @@ public async Task<UsageData> ReadLocalData()
6568
SimpleJson.DeserializeObject<UsageData>(json) :
6669
new UsageData { Model = new UsageModel() };
6770
}
68-
catch
71+
catch(Exception ex)
6972
{
73+
log.Error(ex, "Error deserializing usage");
7074
return new UsageData { Model = new UsageModel() };
7175
}
7276
}
@@ -79,9 +83,9 @@ public async Task WriteLocalData(UsageData data)
7983
var json = SimpleJson.SerializeObject(data);
8084
await WriteAllTextAsync(storePath, json);
8185
}
82-
catch
86+
catch(Exception ex)
8387
{
84-
// log.Warn("Failed to write usage data", ex);
88+
log.Error(ex,"Failed to write usage data");
8589
}
8690
}
8791

0 commit comments

Comments
 (0)