Module: LumberYak

Defined in:
lib/lumberyak.rb,
lib/lumberyak/version.rb

Defined Under Namespace

Classes: LumberYakRailtie

Constant Summary collapse

VERSION =
"0.1.5".freeze

Class Method Summary collapse

Class Method Details

.configObject


63
64
65
# File 'lib/lumberyak.rb', line 63

def config
  application.config.lumberyak
end

.enable_json_loggingObject


58
59
60
61
# File 'lib/lumberyak.rb', line 58

def enable_json_logging
  # Explicitly require our monkey patch to ensure it takes effect.
  require 'activesupport/taggedlogging/formatter.rb'
end

.setup(app) ⇒ Object


14
15
16
17
18
19
20
# File 'lib/lumberyak.rb', line 14

def setup(app)
  self.application = app
  setup_logger
  setup_lograge
  setup_logtags
  enable_json_logging
end

.setup_loggerObject


33
34
35
36
37
38
39
# File 'lib/lumberyak.rb', line 33

def setup_logger
  if application.config.logger
    new_logger = ActiveSupport::TaggedLogging.new(application.config.logger)
    application.config.logger = new_logger
    Rails.logger = new_logger
  end
end

.setup_logrageObject


41
42
43
44
45
46
47
48
49
# File 'lib/lumberyak.rb', line 41

def setup_lograge
  if config.configure_lograge
    application.configure do
      config.lograge.enabled = true
      config.lograge.formatter = Lograge::Formatters::NoFormat.new
    end
    Lograge.setup(application)
  end
end

.setup_logtagsObject


51
52
53
54
55
56
# File 'lib/lumberyak.rb', line 51

def setup_logtags
  application.config.log_tags = config.log_tags if config.log_tags

  # require our dispatcher monkey patch to enable controller/action tags
  require 'action_dispatch/routing/route_set/dispatcher.rb'
end