Skip to content

Commit

Permalink
Merge pull request #130 from awslabs/fix/add-kpl-log-option
Browse files Browse the repository at this point in the history
Add enable_kpl_logging option
  • Loading branch information
riywo authored Sep 22, 2017
2 parents 0e59fc6 + 438e078 commit 1eb44fb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ A key to extract partition key from JSON object. Default `nil`, which means part
### debug
Boolean. Enable if you need to debug Kinesis Producer Library metrics. Default is `false`.

### enable_kpl_logging
Boolean, default `false`. If you want to log KPL binary's stdout/err, make this parameter `true`.

### kinesis_producer
This section is configuration for Kinesis Producer Library. Almost all of description comes from [deault_config.propertites of KPL Java Sample Application][default_config.properties]. You should specify configurations below inside `<kinesis_producer>` section like:

Expand Down
1 change: 1 addition & 0 deletions lib/fluent/plugin/kinesis_helper/class_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def config_param_for_producer
config_param :stream_name_prefix, :string, default: nil
config_param :region, :string, default: nil
config_param :partition_key, :string, default: nil
config_param :enable_kpl_logging, :bool, default: false
config_param_for_credentials
config_param_for_format
config_param_for_debug
Expand Down
1 change: 1 addition & 0 deletions lib/fluent/plugin/kinesis_helper/kpl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def client_options
credentials_refresh_delay: @kinesis_producer.credentials_refresh_delay,
debug: @debug,
logger: log,
enable_kpl_logging: @enable_kpl_logging,
}
end

Expand Down
9 changes: 7 additions & 2 deletions lib/kinesis_producer/daemon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def initialize(binary, handler, options)
@credentials_refresh_delay = options[:credentials_refresh_delay] || 5000
@logger = options[:logger]
@debug = options[:debug]
@enable_kpl_logging = options[:enable_kpl_logging]

@executor = Concurrent::CachedThreadPool.new
@shutdown = Concurrent::AtomicBoolean.new(false)
Expand Down Expand Up @@ -127,9 +128,13 @@ def connect_to_child
@out_channel = @out_pipe.open('w')
end

def enable_kpl_logging?
@enable_kpl_logging
end

def start_loops
start_loop_for(:log_stdout)
start_loop_for(:log_stderr)
start_loop_for(:log_stdout) if enable_kpl_logging?
start_loop_for(:log_stderr) if enable_kpl_logging?
start_loop_for(:send_message)
start_loop_for(:receive_message)
start_loop_for(:return_message)
Expand Down

0 comments on commit 1eb44fb

Please sign in to comment.