Skip to content

Commit

Permalink
Merge pull request #2252 from fluent/fix-plugin-logger-and-id
Browse files Browse the repository at this point in the history
log: Fix plugin logger ignores fluentd log event setting
  • Loading branch information
repeatedly authored Jan 7, 2019
2 parents 6f1ebf9 + e0b4e5c commit d4bc4ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fluent/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def enable_color(b = true)

extend Forwardable
def_delegators '@logger', :get_worker_id, :enable_color?, :enable_debug, :enable_event,
:disable_events, :log_event_enabled, :log_event_enamed=, :time_format, :time_format=,
:disable_events, :log_event_enabled, :log_event_enabled=, :time_format, :time_format=,
:time_formatter, :time_formatter=, :event, :caller_line, :puts, :write, :<<, :flush,
:reset, :out, :out=, :optional_header, :optional_header=, :optional_attrs, :optional_attrs=
end
Expand Down
6 changes: 6 additions & 0 deletions lib/fluent/plugin/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ def context_router
end

def start
# By initialization order, plugin logger is created before set log_event_enabled.
# It causes '@id' specified plugin, it uses plugin logger instead of global logger, ignores `<label @FLUENT_LOG>` setting.
# This is adhoc approach but impact is minimal.
if @log.is_a?(Fluent::PluginLogger) && $log.respond_to?(:log_event_enabled) # log_event_enabled check for tests
@log.log_event_enabled = $log.log_event_enabled
end
@_state.start = true
self
end
Expand Down

0 comments on commit d4bc4ee

Please sign in to comment.