Skip to content

Commit 9d8e79e

Browse files
committed
Update ConsoleLogFactory so it synchronizes access
1 parent e7b7233 commit 9d8e79e

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

lib/ServiceStack.Common.dll

0 Bytes
Binary file not shown.

lib/ServiceStack.Interfaces.dll

512 Bytes
Binary file not shown.

src/TestMqHost/Program.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class Program
1919
static void Main(string[] args)
2020
{
2121

22-
//LogManager.LogFactory = new ConsoleLogFactory();
22+
LogManager.LogFactory = new ConsoleLogFactory();
23+
var log = LogManager.GetLogger(typeof(Program));
2324

2425
var clientManager = new PooledRedisClientManager(new[] { "localhost" })
2526
{
@@ -33,7 +34,7 @@ static void Main(string[] args)
3334
{
3435
var dto = c.GetBody();
3536
sum += dto.Value;
36-
"Received {0}, sum: {1}".Print(dto.Value, sum);
37+
log.InfoFormat("Received {0}, sum: {1}", dto.Value, sum);
3738
return null;
3839
});
3940

@@ -47,14 +48,12 @@ static void Main(string[] args)
4748
{
4849
try
4950
{
50-
lock (clientManager)
51-
"Publish: {0}...".Print(i);
51+
log.InfoFormat("Publish: {0}...", i);
5252
client.Publish(new Incr { Value = i });
5353
}
5454
catch (Exception ex)
5555
{
56-
lock (clientManager)
57-
"Start Publish exception: {0}".Print(ex.Message);
56+
log.InfoFormat("Start Publish exception: {0}", ex.Message);
5857
clientManager.GetClientPoolActiveStates().PrintDump();
5958
clientManager.GetReadOnlyClientPoolActiveStates().PrintDump();
6059
}
@@ -69,16 +68,15 @@ static void Main(string[] args)
6968
{
7069
client.SetConfig("timeout", "1");
7170
var clientAddrs = client.GetClientList().ConvertAll(x => x["addr"]);
72-
lock (clientManager)
73-
"Killing clients: {0}...".Print(clientAddrs.Dump());
71+
log.InfoFormat("Killing clients: {0}...", clientAddrs.Dump());
72+
7473
try
7574
{
7675
clientAddrs.ForEach(client.ClientKill);
7776
}
7877
catch (Exception ex)
7978
{
80-
lock (clientManager)
81-
"Client exception: {0}".Print(ex.Message);
79+
log.InfoFormat("Client exception: {0}", ex.Message);
8280
}
8381
}
8482
});
@@ -89,14 +87,12 @@ static void Main(string[] args)
8987
{
9088
try
9189
{
92-
lock (clientManager)
93-
"Publish: {0}...".Print(i);
90+
log.InfoFormat("Publish: {0}...", i);
9491
client.Publish(new Incr { Value = i });
9592
}
9693
catch (Exception ex)
9794
{
98-
lock (clientManager)
99-
"Publish exception: {0}".Print(ex.Message);
95+
log.InfoFormat("Publish exception: {0}", ex.Message);
10096
clientManager.GetClientPoolActiveStates().PrintDump();
10197
clientManager.GetReadOnlyClientPoolActiveStates().PrintDump();
10298
}

0 commit comments

Comments
 (0)