# # Fluentd # # Copyright (C) 2011 FURUHASHI Sadayuki # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # require 'optparse' require 'fluent/log' require 'fluent/env' require 'fluent/version' op = OptionParser.new op.version = Fluent::VERSION # default values opts = { :config_path => Fluent::DEFAULT_CONFIG_PATH, :plugin_dirs => [Fluent::DEFAULT_PLUGIN_DIR], :log_level => Fluent::Log::LEVEL_INFO, :log_path => nil, :daemonize => false, :libs => [], :setup_path => nil, :chuser => nil, :chgroup => nil, } op.on('-s', "--setup [DIR=#{File.dirname(Fluent::DEFAULT_CONFIG_PATH)}]", "install sample configuration file to the directory") {|s| opts[:setup_path] = s || File.dirname(Fluent::DEFAULT_CONFIG_PATH) } op.on('-c', '--config PATH', "config flie path (default: #{Fluent::DEFAULT_CONFIG_PATH})") {|s| opts[:config_path] = s } op.on('-p', '--plugin DIR', "add plugin directory") {|s| opts[:plugin_dirs] << s } op.on('-I PATH', "add library path") {|s| $LOAD_PATH << s } op.on('-r NAME', "load library") {|s| opts[:libs] << s } op.on('-d', '--daemon PIDFILE', "daemonize fluent process") {|s| opts[:daemonize] = s } op.on('--user USER', "change user") {|s| opts[:chuser] = s } op.on('--group GROUP', "change group") {|s| opts[:chgroup] = s } op.on('-o', '--log PATH', "log file path") {|s| opts[:log_path] = s } op.on('-i', '--inline-config CONFIG_STRING', "inline config which is appended to the config file on-fly") {|s| opts[:inline_config] = s } op.on('-v', '--verbose', "increment verbose level (-v: debug, -vv: trace)", TrueClass) {|b| if b case opts[:log_level] when Fluent::Log::LEVEL_INFO opts[:log_level] = Fluent::Log::LEVEL_DEBUG when Fluent::Log::LEVEL_DEBUG opts[:log_level] = Fluent::Log::LEVEL_TRACE end end } (class<