@@ -19,7 +19,8 @@ class Program
19
19
static void Main ( string [ ] args )
20
20
{
21
21
22
- //LogManager.LogFactory = new ConsoleLogFactory();
22
+ LogManager . LogFactory = new ConsoleLogFactory ( ) ;
23
+ var log = LogManager . GetLogger ( typeof ( Program ) ) ;
23
24
24
25
var clientManager = new PooledRedisClientManager ( new [ ] { "localhost" } )
25
26
{
@@ -33,7 +34,7 @@ static void Main(string[] args)
33
34
{
34
35
var dto = c . GetBody ( ) ;
35
36
sum += dto . Value ;
36
- "Received {0}, sum: {1}" . Print ( dto . Value , sum ) ;
37
+ log . InfoFormat ( "Received {0}, sum: {1}" , dto . Value , sum ) ;
37
38
return null ;
38
39
} ) ;
39
40
@@ -47,14 +48,12 @@ static void Main(string[] args)
47
48
{
48
49
try
49
50
{
50
- lock ( clientManager )
51
- "Publish: {0}..." . Print ( i ) ;
51
+ log . InfoFormat ( "Publish: {0}..." , i ) ;
52
52
client . Publish ( new Incr { Value = i } ) ;
53
53
}
54
54
catch ( Exception ex )
55
55
{
56
- lock ( clientManager )
57
- "Start Publish exception: {0}" . Print ( ex . Message ) ;
56
+ log . InfoFormat ( "Start Publish exception: {0}" , ex . Message ) ;
58
57
clientManager . GetClientPoolActiveStates ( ) . PrintDump ( ) ;
59
58
clientManager . GetReadOnlyClientPoolActiveStates ( ) . PrintDump ( ) ;
60
59
}
@@ -69,16 +68,15 @@ static void Main(string[] args)
69
68
{
70
69
client . SetConfig ( "timeout" , "1" ) ;
71
70
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
+
74
73
try
75
74
{
76
75
clientAddrs . ForEach ( client . ClientKill ) ;
77
76
}
78
77
catch ( Exception ex )
79
78
{
80
- lock ( clientManager )
81
- "Client exception: {0}" . Print ( ex . Message ) ;
79
+ log . InfoFormat ( "Client exception: {0}" , ex . Message ) ;
82
80
}
83
81
}
84
82
} ) ;
@@ -89,14 +87,12 @@ static void Main(string[] args)
89
87
{
90
88
try
91
89
{
92
- lock ( clientManager )
93
- "Publish: {0}..." . Print ( i ) ;
90
+ log . InfoFormat ( "Publish: {0}..." , i ) ;
94
91
client . Publish ( new Incr { Value = i } ) ;
95
92
}
96
93
catch ( Exception ex )
97
94
{
98
- lock ( clientManager )
99
- "Publish exception: {0}" . Print ( ex . Message ) ;
95
+ log . InfoFormat ( "Publish exception: {0}" , ex . Message ) ;
100
96
clientManager . GetClientPoolActiveStates ( ) . PrintDump ( ) ;
101
97
clientManager . GetReadOnlyClientPoolActiveStates ( ) . PrintDump ( ) ;
102
98
}
0 commit comments