Class: PostHog::PrefixedLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/posthog/logging.rb

Overview

Wraps an existing logger and adds a prefix to all messages

Instance Method Summary collapse

Constructor Details

#initialize(logger, prefix) ⇒ PrefixedLogger

Returns a new instance of PrefixedLogger.



6
7
8
9
# File 'lib/posthog/logging.rb', line 6

def initialize(logger, prefix)
  @logger = logger
  @prefix = prefix
end

Instance Method Details

#debug(msg) ⇒ Object



11
12
13
# File 'lib/posthog/logging.rb', line 11

def debug(msg)
  @logger.debug("#{@prefix} #{msg}")
end

#error(msg) ⇒ Object



23
24
25
# File 'lib/posthog/logging.rb', line 23

def error(msg)
  @logger.error("#{@prefix} #{msg}")
end

#info(msg) ⇒ Object



15
16
17
# File 'lib/posthog/logging.rb', line 15

def info(msg)
  @logger.info("#{@prefix} #{msg}")
end

#levelObject



31
32
33
# File 'lib/posthog/logging.rb', line 31

def level
  @logger.level
end

#level=(severity) ⇒ Object



27
28
29
# File 'lib/posthog/logging.rb', line 27

def level=(severity)
  @logger.level = severity
end

#warn(msg) ⇒ Object



19
20
21
# File 'lib/posthog/logging.rb', line 19

def warn(msg)
  @logger.warn("#{@prefix} #{msg}")
end