Skip to content

Commit 0925793

Browse files
authored
Merge pull request #317 from robertcheramy/fix/316-syslog-timestamp
Fix syslog messages contains two timestamps
2 parents dfefc46 + a7e5dd3 commit 0925793

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [unreleased]
77

8+
## [4.17.0]
9+
810
- Correct `source_code_uri` URL
11+
- Add :notime as a time_format for Formatters
12+
- Fix #316: syslog messages contains two timestamps
913
- Add appender for CloudWatch Logs
1014
- NR Integration: Ensures key/values are not nested under `messages`
1115
- NR Integration: Ensures structures are built for all nested json (I.E build an actual object instead of doing `span.id` as the key)

lib/semantic_logger/appender/syslog.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def flush
215215
def default_formatter
216216
if protocol == :syslog
217217
# Format is text output without the time
218-
SemanticLogger::Formatters::Default.new(time_format: nil)
218+
SemanticLogger::Formatters::Default.new(time_format: :notime)
219219
else
220220
SemanticLogger::Formatters::Syslog.new(facility: facility, level_map: level_map, max_size: max_size)
221221
end

lib/semantic_logger/formatters/base.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Base
2323
# See Time#strftime for the format of this string.
2424
# :iso_8601 Outputs an ISO8601 Formatted timestamp.
2525
# :ms Output in miliseconds since epoch.
26+
# :notime Returns an empty string for time ( no time is output ).
2627
# Default: '%Y-%m-%d %H:%M:%S.%<precision>N'
2728
# log_host: [Boolean]
2829
# Whether or not to include hostname in logs
@@ -81,7 +82,7 @@ def format_time(time)
8182
time
8283
when :seconds
8384
time.to_f
84-
when nil
85+
when :notime
8586
""
8687
else
8788
time.strftime(time_format)

test/appender/syslog_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class SyslogTest < Minitest::Test
1414
syslog_appender.debug "AppenderSyslogTest log message"
1515
end
1616
end
17-
assert_match(/D (.*?) SemanticLogger::Appender::Syslog -- AppenderSyslogTest log message/, message)
17+
assert_match(/^ D (.*?) SemanticLogger::Appender::Syslog -- AppenderSyslogTest log message/, message)
1818
end
1919

2020
it "handle remote syslog over TCP" do

0 commit comments

Comments
 (0)