Module: VidazingLogger

Defined in:
lib/vidazing_logger.rb,
lib/vidazing_logger/version.rb,
lib/vidazing_logger/appenders/log.rb,
lib/vidazing_logger/filters/error.rb,
lib/vidazing_logger/appenders/type.rb,
lib/vidazing_logger/filters/normal.rb,
lib/vidazing_logger/layout_pattern.rb,
lib/vidazing_logger/appenders/basic.rb,
lib/vidazing_logger/appenders/stderr.rb,
lib/vidazing_logger/appenders/stdout.rb,
lib/vidazing_logger/appenders/log/build.rb,
lib/vidazing_logger/appenders/log/error.rb,
lib/vidazing_logger/colors/color_scheme.rb,
lib/vidazing_logger/colors/error_color_scheme.rb,
lib/vidazing_logger/colors/normal_color_scheme.rb

Overview

Namespace for the convenience method to create a new logger

See Also:

Since:

  • 0.1.0

Defined Under Namespace

Modules: Appenders, Colors, Filters Classes: ColorScheme, LayoutPattern

Constant Summary collapse

LOG_DIR =
String

Since:

  • 0.1.0

'logs'
VERSION =
String

Since:

  • 0.1.0

'0.1.0'

Class Method Summary collapse

Class Method Details

.cleanObject

Deletes the 'logs/' directory

Since:

  • 0.1.0


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

def clean
  FileUtils.remove_dir(LOG_DIR, true)
end

.initializeObject

Creates the 'logs/' directory

Since:

  • 0.1.0


21
22
23
# File 'lib/vidazing_logger.rb', line 21

def initialize
  Dir.mkdir(LOG_DIR) unless Dir.exist?(LOG_DIR)
end

.logger(name = 'VidaZing') ⇒ Logging.logger

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

Parameters:

  • name (String) (defaults to: 'VidaZing')

    Logger name used in messages

Returns:

Since:

  • 0.1.0


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/vidazing_logger.rb', line 36

def logger(name = 'VidaZing')
  VidazingLogger.initialize

  stdout = VidazingLogger::Appenders::Stdout.new
  build_log = VidazingLogger::Appenders::BuildLog.new(log_dir: LOG_DIR)

  stderr = VidazingLogger::Appenders::Stderr.new
  error_log = VidazingLogger::Appenders::ErrorLog.new(log_dir: LOG_DIR)

  log = Logging.logger[name]
  log.add_appenders \
    stdout.appender,
    build_log.appender,
    stderr.appender,
    error_log.appender

  log
end