Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changesets/auto-detect-log-format.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: patch
type: change
---

Detect the log format automatically. By default we now detect if a log line is JSON or plaintext. No further config needed.
4 changes: 3 additions & 1 deletion lib/appsignal/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def to_proc
# @!visibility private
JSON = 2
# @!visibility private
AUTODETECT = 3
# @!visibility private
SEVERITY_MAP = {
DEBUG => 2,
INFO => 3,
Expand All @@ -73,7 +75,7 @@ def to_proc
# @param format [Integer] Format to use to parse log line attributes.
# @param attributes [Hash<String, String>] Default attributes for all log lines.
# @return [void]
def initialize(group, level: INFO, format: PLAINTEXT, attributes: {})
def initialize(group, level: INFO, format: AUTODETECT, attributes: {})
raise TypeError, "group must be a string" unless group.is_a? String

@group = group
Expand Down
2 changes: 1 addition & 1 deletion sig/appsignal.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ module Appsignal
attributes: T::Hash[String, String]
).void
end
def initialize(group, level: INFO, format: PLAINTEXT, attributes: {}); end
def initialize(group, level: INFO, format: AUTODETECT, attributes: {}); end

# Sets the formatter for this logger and all broadcasted loggers.
#
Expand Down
Loading
Loading