#!/usr/bin/env ruby $:.unshift File.expand_path("../../lib", __FILE__) require 'zlogger' require 'optparse' # Process options options = {} opts = OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options]" opts.separator "" opts.separator "Specific options:" opts.on("-b", "--bind ADDRESS", "TCP address to bind to, defaults to 0.0.0.0") do |ext| options[:bind_address] = ext end opts.on("-p", "--port PORT", Integer, "Port number to bind to") do |n| options[:port] = n end opts.on("-f", '--file FILE', String, "File to write the log to. File is stored under /log folder") do |file| options[:output] = file end opts.on("-r", '--rotate', String, "Rotate log file daily") do |file| options[:rotate] = true end opts.on("-s", "--stdout", "Echo output to STDOUT (only applicable when -f is used)") do options[:stdout] = true end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("-v", "--version", "Show version") do puts "Zlogger version #{Zlogger::VERSION}" exit end end opts.parse!(ARGV) # Create Zlogger logger = Zlogger::Daemon.new(options) logger.run