Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #20 from uShip/MAX/707-fix-count-subkey
Browse files Browse the repository at this point in the history
MAX-707: Fix count subkey
  • Loading branch information
jayflaherty75 authored Jul 2, 2021
2 parents 8819f2d + 90d2e64 commit 3c0a777
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/uShip.Logging.Tests/LoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,22 @@ public void should_format_message_properly_for_graphite_counter_with_subkey()
log.Received().Info(expectedValue);
}

[Test]
public void should_format_message_properly_for_count_method_with_subkey()
{
var logFactory = Substitute.For<LogFactory>();
var log = Substitute.For<ILog>();
logFactory.Create(ConfiguredLogger.Graphite).Returns(log);

var logger = new Logger(logFactory, Substitute.For<LoggingEventDataBuilder>());
logger.Count(GraphiteKey.Test.Key, "SubKey", 1);

var hostName = Environment.MachineName;
var expectedValue = String.Format("graphite.test.Test.SubKey~source={0}:1|c", hostName);

log.Received().Info(expectedValue);
}

[Test]
public void should_format_message_properly_for_graphite_counter_with_subkey_with_tags()
{
Expand Down
2 changes: 1 addition & 1 deletion src/uShip.Logging/LogBuilders/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void Count(string key, int count, Dictionary<string, string> tags = null)

public void Count(string key, string subkey, int count, Dictionary<string, string> tags = null)
{
var message = FormatGraphiteMessage(key, null, null, count, tags);
var message = FormatGraphiteMessage(key, subkey, null, count, tags);
_graphiteLog.Info(message);
}

Expand Down

0 comments on commit 3c0a777

Please sign in to comment.