class VidazingLogger::Logger

Core Logger class api. Calling build returns a logger with 4 +Appender+s attached.

@since 0.2.0

Attributes

log_dir[R]

Where to write logs to

@return [String] where to write logs to

name[R]

Use in Logging.logger

@return [String] name

Public Class Methods

new(log_dir = VidazingLogger::LOG_DIR, name:) click to toggle source

Creates the 'logs/' directory

@param name [String] Logger name used in messages @param log_dir [String] Directory to write logs in

# File lib/vidazing_logger/logger.rb, line 25
def initialize(log_dir = VidazingLogger::LOG_DIR, name:)
  @name = name
  @log_dir = log_dir

  create_log_dir
end

Public Instance Methods

build() click to toggle source

Create a Logger with 4 Appenders. STDERR + 'logs/error.log' STDOUT + 'logs/build.log'

@return [Logging.logger] See github.com/TwP/logging/blob/master/lib/logging/logger.rb

# File lib/vidazing_logger/logger.rb, line 42
def build
  LoggerBuilder.build(name: @name) do |builder|
    builder
      .add_stdout
      .add_build_log(log_dir: @log_dir)
      .add_stderr
      .add_error_log(log_dir: @log_dir)
  end
end
clean() click to toggle source

Deletes the log_dir directory

# File lib/vidazing_logger/logger.rb, line 33
def clean
  FileUtils.remove_dir(@log_dir, true)
end

Private Instance Methods

create_log_dir() click to toggle source
# File lib/vidazing_logger/logger.rb, line 54
def create_log_dir
  Dir.mkdir(@log_dir) unless Dir.exist?(@log_dir)
end