Sha256: b193d9493469f4785f2b30c14848b523282d190e0cf93b9de2c5b36665b701d9

Contents?: true

Size: 963 Bytes

Versions: 1

Compression:

Stored size: 963 Bytes

Contents

require 'fileutils'
class ApplicationController < Sinatra::Base
  set :logger, Lumberjack::Logger.new
  helpers { def logger() settings.logger end }

  configure(:test) { disable :logging }
  configure(:development) { enable :logging }

  # Environments where STDOUT should be redirected to log file
  %i[production].each do |app_env|
    configure app_env do
      enable :logging
      use Rack::CommonLogger, $stdout

      time = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
      log_path = Eucalypt.path 'log', time.sub(/_\+/, ?p).sub(/_\-/, ?m)
      FileUtils.mkdir_p log_path

      $stderr.reopen File.new(File.join(log_path, "#{app_env}.stderr.log"), 'a+')
      $stderr.sync = true
      $stdout.reopen File.new(File.join(log_path, "#{app_env}.stdout.log"), 'a+')
      $stdout.sync = true
    end
  end

  # ActiveRecord logging
  ActiveRecord::Base.logger = Logger.new STDOUT
  ActiveRecord::Migration.verbose = true # Set to false for quieter logging
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eucalypt-0.4.0 lib/eucalypt/core/templates/eucalypt/config/logging.rb