From 6f7d07530a365b122eeffe3e5c66dcece6234b24 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 25 Aug 2018 16:59:54 -0400 Subject: [PATCH] log domain with warnings --- src/Icons/Controllers/IconsController.cs | 4 ++-- src/Icons/Services/IconFetchingService.cs | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Icons/Controllers/IconsController.cs b/src/Icons/Controllers/IconsController.cs index 8dae7a4e2b..52797a9e5d 100644 --- a/src/Icons/Controllers/IconsController.cs +++ b/src/Icons/Controllers/IconsController.cs @@ -58,7 +58,7 @@ namespace Bit.Icons.Controllers var result = await _iconFetchingService.GetIconAsync(domain); if(result == null) { - _logger.LogInformation("Null result returned."); + _logger.LogWarning("Null result returned for {0}.", domain); icon = null; } else @@ -69,7 +69,7 @@ namespace Bit.Icons.Controllers // Only cache not found and smaller images (<= 50kb) if(_iconsSettings.CacheEnabled && (icon == null || icon.Image.Length <= 50012)) { - _logger.LogInformation("Cache the icon."); + _logger.LogWarning("Cache the icon for {0}.", domain); _memoryCache.Set(mappedDomain, icon, new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = new TimeSpan(_iconsSettings.CacheHours, 0, 0), diff --git a/src/Icons/Services/IconFetchingService.cs b/src/Icons/Services/IconFetchingService.cs index 980adf2b3c..e252a87e9d 100644 --- a/src/Icons/Services/IconFetchingService.cs +++ b/src/Icons/Services/IconFetchingService.cs @@ -55,7 +55,7 @@ namespace Bit.Icons.Services { if(!Uri.TryCreate($"https://{domain}", UriKind.Absolute, out var parsedHttpsUri)) { - _logger.LogInformation("Bad domain."); + _logger.LogWarning("Bad domain: {0}.", domain); return null; } @@ -90,7 +90,8 @@ namespace Bit.Icons.Services if(response?.Content == null || !response.IsSuccessStatusCode) { - _logger.LogInformation("Couldn't load a website: {0}.", response?.StatusCode.ToString() ?? "null"); + _logger.LogWarning("Couldn't load a website for {0}: {1}.", domain, + response?.StatusCode.ToString() ?? "null"); Cleanup(response); return null; } @@ -103,7 +104,7 @@ namespace Bit.Icons.Services uri = response.RequestMessage.RequestUri; if(document.DocumentElement == null) { - _logger.LogInformation("No DocumentElement."); + _logger.LogWarning("No DocumentElement for {0}.", domain); return null; } @@ -204,7 +205,7 @@ namespace Bit.Icons.Services } else { - _logger.LogInformation("No favicon.ico found."); + _logger.LogWarning("No favicon.ico found for {0}.", uri.Host); return null; } }