Skip to content

Commit 244a0a8

Browse files
committed
Get rid of prefix logger and its dependency on nlog
1 parent a61f318 commit 244a0a8

16 files changed

Lines changed: 17 additions & 119 deletions

File tree

src/Blockcore.ruleset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<Description Resource="MinimumRecommendedRules_Description" />
66
</Localization>
77
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
8+
<Rule Id="SA0001" Action="None" />
89
<Rule Id="CS0618" Action="Info" />
910
<Rule Id="CA1001" Action="Warning" />
1011
<Rule Id="CA1009" Action="Warning" />

src/Blockcore/BlockPulling/BlockPullerBehavior.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public BlockPullerBehavior(IBlockPuller blockPuller, IInitialBlockDownloadState
117117

118118
this.blockPuller = blockPuller;
119119

120-
this.logger = loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.GetHashCode():x}] ");
120+
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
121121
this.loggerFactory = loggerFactory;
122122
}
123123

src/Blockcore/Connection/ConnectionManagerBehavior.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class ConnectionManagerBehavior : NetworkPeerBehavior, IConnectionManager
3838

3939
public ConnectionManagerBehavior(IConnectionManager connectionManager, ILoggerFactory loggerFactory)
4040
{
41-
this.logger = loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.GetHashCode():x}] ");
41+
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
4242
this.infoLogger = loggerFactory.CreateLogger(this.GetType().FullName);
4343
this.loggerFactory = loggerFactory;
4444

src/Blockcore/Connection/DropNodesBehaviour.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class DropNodesBehaviour : NetworkPeerBehavior
3434

3535
public DropNodesBehaviour(ChainIndexer chainIndexer, IConnectionManager connectionManager, ILoggerFactory loggerFactory)
3636
{
37-
this.logger = loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.GetHashCode():x}] ");
37+
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
3838
this.loggerFactory = loggerFactory;
3939

4040
this.chainIndexer = chainIndexer;

src/Blockcore/Consensus/ConsensusManagerBehavior.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public ConsensusManagerBehavior(ChainIndexer chainIndexer, IInitialBlockDownload
8484
this.asyncLock = new AsyncLock();
8585
this.bestSentHeaderLock = new object();
8686

87-
this.logger = loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.GetHashCode():x}] ");
87+
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
8888
}
8989

9090
/// <summary>Presents cached headers to <see cref="Consensus.ConsensusManager"/> from the cache if any and removes consumed from the cache.</summary>

src/Blockcore/P2P/Peer/NetworkPeer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public NetworkPeer(IPEndPoint peerEndPoint,
352352

353353
this.Connection = networkPeerFactory.CreateNetworkPeerConnection(this, client, this.ProcessMessageAsync);
354354

355-
this.logger = loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.Connection.Id}-{peerEndPoint}] ");
355+
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
356356
}
357357

358358
/// <summary>
@@ -382,7 +382,7 @@ public NetworkPeer(IPEndPoint peerEndPoint,
382382
{
383383
this.Connection = networkPeerFactory.CreateNetworkPeerConnection(this, client, this.ProcessMessageAsync);
384384

385-
this.logger = loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.Connection.Id}-{peerEndPoint}] ");
385+
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
386386

387387
this.logger.LogDebug("Connected to peer '{0}'.", this.PeerEndPoint);
388388

src/Blockcore/P2P/Peer/NetworkPeerConnection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public NetworkPeerConnection(Network network, INetworkPeer peer, TcpClient clien
9999
this.loggerFactory = loggerFactory;
100100
this.payloadProvider = payloadProvider;
101101
this.asyncProvider = Guard.NotNull(asyncProvider, nameof(asyncProvider));
102-
this.logger = this.loggerFactory.CreateLogger(this.GetType().FullName, $"[{clientId}-{peer.PeerEndPoint}] ");
102+
this.logger = this.loggerFactory.CreateLogger(this.GetType().FullName);
103103

104104
this.network = network;
105105
this.dateTimeProvider = dateTimeProvider;
@@ -172,7 +172,7 @@ private async Task ReceiveMessagesAsync()
172172
/// <exception cref="OperationCanceledException">Thrown when the connection attempt was aborted.</exception>
173173
public async Task ConnectAsync(IPEndPoint endPoint, CancellationToken cancellation)
174174
{
175-
this.logger = this.loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.Id}-{endPoint}] ");
175+
this.logger = this.loggerFactory.CreateLogger(this.GetType().FullName);
176176

177177
try
178178
{

src/Blockcore/P2P/Peer/NetworkPeerServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public NetworkPeerServer(Network network,
9191
IPeerAddressManager peerAddressManager,
9292
IDateTimeProvider dateTimeProvider)
9393
{
94-
this.logger = loggerFactory.CreateLogger(this.GetType().FullName, $"[{localEndPoint}] ");
94+
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
9595
this.signals = asyncProvider.Signals;
9696
this.networkPeerFactory = networkPeerFactory;
9797
this.networkPeerDisposer = new NetworkPeerDisposer(loggerFactory, asyncProvider);

src/Blockcore/P2P/PeerAddressManagerBehaviour.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public PeerAddressManagerBehaviour(IDateTimeProvider dateTimeProvider, IPeerAddr
5757
Guard.NotNull(peerAddressManager, nameof(loggerFactory));
5858

5959
this.dateTimeProvider = dateTimeProvider;
60-
this.logger = loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.GetHashCode():x}] ");
60+
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
6161
this.loggerFactory = loggerFactory;
6262
this.peerBanning = peerBanning;
6363
this.Mode = PeerAddressManagerBehaviourMode.AdvertiseDiscover;

src/Blockcore/P2P/Protocol/Behaviors/EnforcePeerVersionCheckBehavior.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public EnforcePeerVersionCheckBehavior(ChainIndexer chainIndexer,
5151
this.NodeSettings = nodeSettings;
5252
this.Network = network;
5353
this.LoggerFactory = loggerFactory;
54-
this.Logger = loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.GetHashCode():x}] ");
54+
this.Logger = loggerFactory.CreateLogger(this.GetType().FullName);
5555
}
5656

5757
protected Task OnMessageReceivedAsync(INetworkPeer peer, IncomingMessage message)

0 commit comments

Comments
 (0)