Skip to content

Commit

Permalink
adding nullable contingencies
Browse files Browse the repository at this point in the history
  • Loading branch information
slorello89 committed Feb 4, 2020
1 parent 3c07b8c commit f7fc6a0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Nexmo.Api/Logger/LogProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using System.Collections.Generic;
using System;
namespace Nexmo.Api.Logger
Expand All @@ -10,7 +11,7 @@ public static class LogProvider

public static void SetLogFactory(ILoggerFactory factory)
{
_loggerFactory.Dispose();
_loggerFactory?.Dispose();
_loggerFactory = factory;
_loggers.Clear();
}
Expand All @@ -19,7 +20,7 @@ public static ILogger GetLogger(string category)
{
if (!_loggers.ContainsKey(category))
{
_loggers[category] = _loggerFactory.CreateLogger(category);
_loggers[category] = _loggerFactory?.CreateLogger(category)?? NullLogger.Instance;
}
return _loggers[category];
}
Expand Down

0 comments on commit f7fc6a0

Please sign in to comment.