Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 0 additions & 10 deletions .changesets/add-log-format-autodetect-option.md

This file was deleted.

11 changes: 11 additions & 0 deletions .changesets/auto-detect-log-format.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
bump: patch
type: change
---

Detect the log format automatically. We now detect if a log line is in the JSON, Logfmt or plaintext formats. No further config needed when calling our logger, like so:

```ruby
logger = Appsignal::Logger.new("gruop")
logger.info("message")
```
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