Sha256: dfd9691e893ced02748b67e6124ae975ea8aa7a0b54d9d0d4a7ccac73d7a07c5

Contents?: true

Size: 952 Bytes

Versions: 2

Compression:

Stored size: 952 Bytes

Contents

# Log4r can be configured using YAML to email using STARTTLS. This example uses gmail.yaml

$: << File.join('..','lib') # path if log4r is not installed
require 'log4r-color'
require 'log4r-color/yamlconfigurator'
# we use various outputters, so require them, otherwise config chokes
require 'log4r-color/outputter/datefileoutputter'
require 'log4r-color/outputter/emailoutputter'
include Log4r

cfg = YamlConfigurator # shorthand
cfg['HOME'] = '.'      # the only parameter in the YAML, our HOME directory

# load the YAML file with this
cfg.load_yaml_file('gmail.yaml')

# Method to log each of the custom levels
def do_logging(log)
  log.deb "This is DEB"
  log.inf "This is INF"
  log.prt "This is PRT"
  log.wrn "This is WRN"
  log.err "This is ERR"
  log.fat "This is FAT"
end

# turn off the email outputter
Outputter['email'].level = WRN
# the other two outputters log to stderr and a timestamped file in ./logs
do_logging( Logger['mylogger'])

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
log4r-color-1.2.2 examples/gmail.rb
log4r-color-1.2 examples/gmail.rb