diff --git a/app/controllers/fluentd/settings/out_stdout_controller.rb b/app/controllers/fluentd/settings/out_stdout_controller.rb
new file mode 100644
index 0000000..b43f71d
--- /dev/null
+++ b/app/controllers/fluentd/settings/out_stdout_controller.rb
@@ -0,0 +1,9 @@
+class Fluentd::Settings::OutStdoutController < ApplicationController
+ include SettingConcern
+
+ private
+
+ def target_class
+ Fluentd::Setting::OutStdout
+ end
+end
diff --git a/app/models/fluentd/setting/out_stdout.rb b/app/models/fluentd/setting/out_stdout.rb
new file mode 100644
index 0000000..51ba319
--- /dev/null
+++ b/app/models/fluentd/setting/out_stdout.rb
@@ -0,0 +1,37 @@
+class Fluentd
+ module Setting
+ class OutStdout
+ include Common
+
+ KEYS = [:match, :output_type].freeze
+
+ attr_accessor(*KEYS)
+
+ choice :output_type, %w(json hash)
+
+ validates :match, presence: true
+ validates :output_type, inclusion: { in: %w(json hash) }
+
+ def self.initial_params
+ {
+ match: "debug.**",
+ output_type: "json",
+ }
+ end
+
+ def common_options
+ [
+ :match, :output_type
+ ]
+ end
+
+ def advanced_options
+ []
+ end
+
+ def plugin_name
+ "stdout"
+ end
+ end
+ end
+end
diff --git a/app/views/fluentd/settings/source_and_output.html.haml b/app/views/fluentd/settings/source_and_output.html.haml
index 1164d64..09fa2fb 100644
--- a/app/views/fluentd/settings/source_and_output.html.haml
+++ b/app/views/fluentd/settings/source_and_output.html.haml
@@ -29,6 +29,10 @@
.panel-heading
%h4= t('.out')
.panel-body
+ %p
+ = link_to(daemon_setting_out_stdout_path(@fluentd)) do
+ = icon('fa-file-text-o fa-lg')
+ = t("fluentd.common.setup_out_stdout")
%p
= link_to(daemon_setting_out_td_path(@fluentd)) do
= icon('fa-file-text-o fa-lg')
diff --git a/config/locales/translation_en.yml b/config/locales/translation_en.yml
index 40d3d3b..283ede8 100644
--- a/config/locales/translation_en.yml
+++ b/config/locales/translation_en.yml
@@ -100,6 +100,7 @@ en:
setup_in_monitor_agent: Monitoring Agent
setup_out_td: Treasure Data
setup_out_mongo: MongoDB
+ setup_out_stdout: stdout (log)
setup_out_forward: Forwarding
setup_out_s3: Amazon S3
setup_out_elasticsearch: Elasticsearch
@@ -162,6 +163,11 @@ en:
For each config parameter, please refer to the MongoDB output plugin documentation page.
show:
page_title: Add Output to MongoDB
+ out_stdout:
+ option_guide: |
+ Print events to STDOUT (or fluentd log file if launched with daemon mode). Please refer to the stdout output plugin documentation page.
+ show:
+ page_title: stdout (log)
in_syslog:
option_guide: |
For each config parameter, please refer to the MongoDB output plugin documentation page.
diff --git a/config/locales/translation_ja.yml b/config/locales/translation_ja.yml
index 89f609f..1a9fb1d 100644
--- a/config/locales/translation_ja.yml
+++ b/config/locales/translation_ja.yml
@@ -98,6 +98,7 @@ ja:
setup_in_syslog: syslogプロトコル
setup_in_monitor_agent: 監視エージェント
setup_out_td: Treasure Data
+ setup_out_stdout: 標準出力(ログ)
setup_out_mongo: MongoDB
setup_out_forward: 転送
setup_out_s3: AWS S3
@@ -163,6 +164,12 @@ ja:
out_mongoプラグインの解説もご参照ください。
show:
page_title: MongoDB書き出し設定
+ out_stdout:
+ option_guide: |
+ 標準出力(デーモンとして起動しているときはログファイル)へイベントを書き出します。
+ out_stdoutプラグインの解説もご参照ください。
+ show:
+ page_title: 標準出力(ログ)
in_syslog:
option_guide: |
in_syslogプラグイン解説ページもご参照ください。
diff --git a/config/routes.rb b/config/routes.rb
index d19a35d..1afcd06 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -32,6 +32,10 @@ Rails.application.routes.draw do
post "finish"
end
+ resource :out_stdout, only: [:show], module: :settings, controller: :out_stdout do
+ post "finish"
+ end
+
resource :out_mongo, only: [:show], module: :settings, controller: :out_mongo do
post "finish"
end
diff --git a/spec/features/fluentd/setting/out_stdout_spec.rb b/spec/features/fluentd/setting/out_stdout_spec.rb
new file mode 100644
index 0000000..3d27b0b
--- /dev/null
+++ b/spec/features/fluentd/setting/out_stdout_spec.rb
@@ -0,0 +1,35 @@
+require "spec_helper"
+
+describe "out_stdout" do
+ let(:exists_user) { build(:user) }
+ let(:daemon) { build(:fluentd, variant: "td-agent") }
+ let(:match) { "stdout.**" }
+
+ before do
+ Fluentd.stub(:instance).and_return(daemon)
+ Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true)
+ daemon.agent.config_write ""
+
+ visit '/sessions/new'
+ within("form") do
+ fill_in 'session_name', :with => exists_user.name
+ fill_in 'session_password', :with => exists_user.password
+ end
+ click_button I18n.t("terms.sign_in")
+ end
+
+ it "Shown form with filled in td.*.* on match" do
+ visit daemon_setting_out_stdout_path
+ page.should have_css('input[name="fluentd_setting_out_stdout[match]"]')
+ end
+
+ it "Updated config after submit" do
+ daemon.agent.config.should_not include(match)
+ visit daemon_setting_out_stdout_path
+ within('#new_fluentd_setting_out_stdout') do
+ fill_in "Match", with: match
+ end
+ click_button I18n.t("fluentd.common.finish")
+ daemon.agent.config.should include(match)
+ end
+end