Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 02b3e42

Browse files
committed
added some logging
1 parent 09c3ba0 commit 02b3e42

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ServiceStack.Redis/RedisSentinelWorker.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using ServiceStack;
2+
using ServiceStack.Logging;
23
using ServiceStack.Redis;
34
using System;
45
using System.Collections.Generic;
@@ -12,6 +13,8 @@ namespace ServiceStack.Redis
1213
{
1314
internal class RedisSentinelWorker : IDisposable
1415
{
16+
protected static readonly ILog Log = LogManager.GetLogger(typeof(RedisSentinelWorker));
17+
1518
private RedisClient sentinelClient;
1619
private RedisClient sentinelPubSubClient;
1720
private PooledRedisClientManager clientsManager;
@@ -29,6 +32,8 @@ public RedisSentinelWorker(string host, string sentinelName, PooledRedisClientMa
2932
this.sentinelSubscription = this.sentinelPubSubClient.CreateSubscription();
3033
this.sentinelSubscription.OnMessage = SentinelMessageReceived;
3134
this.clientsManager = clientsManager;
35+
36+
Log.Info("Set up Redis Sentinel on {0}".Fmt(host));
3237
}
3338

3439
private void SubscribeForChanges(object arg)
@@ -40,6 +45,7 @@ private void SubscribeForChanges(object arg)
4045
}
4146
catch (Exception)
4247
{
48+
Log.Error("Problem Subscribing to Redis Channel on {0}:{1}".Fmt(this.sentinelClient.Host, this.sentinelClient.Port));
4349
// problem communicating to sentinel
4450
if (SentinelError != null)
4551
{
@@ -55,11 +61,11 @@ private void SubscribeForChanges(object arg)
5561
/// <param name="message"></param>
5662
private void SentinelMessageReceived(string channel, string message)
5763
{
58-
Debug.WriteLine("{0} - {1}".Fmt(channel, message));
59-
6064
// {+|-}sdown is the event for server coming up or down
6165
if (channel.ToLower().Contains("sdown"))
6266
{
67+
Log.Info("Sentinel detected server down/up with message:{0}".Fmt(message));
68+
6369
ConfigureRedisFromSentinel();
6470
}
6571
}
@@ -69,6 +75,8 @@ private void SentinelMessageReceived(string channel, string message)
6975
/// </summary>
7076
private void ConfigureRedisFromSentinel()
7177
{
78+
Log.Info("Configuring Redis Clients");
79+
7280
var masters = ConvertMasterArrayToList(this.sentinelClient.Sentinel("master", this.sentinelName));
7381
var slaves = ConvertSlaveArrayToList(this.sentinelClient.Sentinel("slaves", this.sentinelName));
7482

0 commit comments

Comments
 (0)