Class: HeadlessBrowserTool::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/headless_browser_tool/logger.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.instanceObject

Returns the value of attribute instance.



10
11
12
# File 'lib/headless_browser_tool/logger.rb', line 10

def instance
  @instance
end

Class Method Details

.initialize_logger(mode: :http) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/headless_browser_tool/logger.rb', line 12

def initialize_logger(mode: :http)
  @instance = if mode == :stdio
                # In stdio mode, write to log file
                log_file = File.join(DirectorySetup::LOGS_DIR, "#{Process.pid}.log")
                ::Logger.new(log_file, progname: "HBT")
              else
                # In HTTP mode, write to stdout
                ::Logger.new($stdout, progname: "HBT")
              end

  @instance.level = ::Logger::INFO
  @instance
end

.logObject



26
27
28
# File 'lib/headless_browser_tool/logger.rb', line 26

def log
  @instance ||= initialize_logger
end