Sha256: 891f8976fc012f9ed2fa60e4f3aa011f5d08716fb0a3e16c8e7cbe9224751719

Contents?: true

Size: 672 Bytes

Versions: 5

Compression:

Stored size: 672 Bytes

Contents

class ApplicationController < Sinatra::Base
  set :logger, Lumberjack::Logger.new

  require 'fileutils'
  %i[production test].each do |e|
    configure e do
      use Rack::CommonLogger, $stdout

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

      # STDERR logger
      $stderr.reopen File.new(File.join(log_path, "#{e}.stderr.log"), 'a+')
      $stderr.sync = true

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

  helpers do
    def logger
      settings.logger
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
eucalypt-0.3.2 lib/eucalypt/core/templates/eucalypt/config/logging.rb
eucalypt-0.3.1 lib/eucalypt/core/templates/eucalypt/config/logging.rb
eucalypt-0.3.0 lib/eucalypt/core/templates/eucalypt/config/logging.rb
eucalypt-0.2.2 lib/eucalypt/eucalypt-core/templates/eucalypt/config/logging.rb
eucalypt-0.2.1 lib/eucalypt/eucalypt-core/templates/eucalypt/config/logging.rb