Logger is now thread safe.
This commit is contained in:
parent
455efcbfe3
commit
89b23258aa
@ -1,10 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace GameServiceWarden.Core.Logging
|
namespace GameServiceWarden.Core.Logging
|
||||||
{
|
{
|
||||||
public static class Logger {
|
public static class Logger {
|
||||||
private static readonly Dictionary<string, ILogReceiver> listeners = new Dictionary<string, ILogReceiver>();
|
private static readonly ConcurrentDictionary<string, ILogReceiver> listeners = new ConcurrentDictionary<string, ILogReceiver>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logs the message to listeners that are listening to the set severity of the message or greater.
|
/// Logs the message to listeners that are listening to the set severity of the message or greater.
|
||||||
@ -33,7 +34,8 @@ namespace GameServiceWarden.Core.Logging
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="listener">The listener to remove.</param>
|
/// <param name="listener">The listener to remove.</param>
|
||||||
public static void RemoveLogListener(ILogReceiver listener) {
|
public static void RemoveLogListener(ILogReceiver listener) {
|
||||||
listeners.Remove(listener.Identifier);
|
ILogReceiver receiver;
|
||||||
|
listeners.TryRemove(listener.Identifier, out receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user