module Utter

Utter defines its interfacing points here. Utter communicate seamlessly 
via this facade pattern to its internals. This allows all Utter applications 
makes it easy to have consistant improvments without updating their codebases.

NOTE According to Semantic Versioning 2.0.0 (semver.org/); Any changes

to this file would require an upgrade to a new Major version.

require 'net/http' #TODO not needed as calling other services is done in Utter Domain Extensions, Net::HTTP.get('example.com', '/index.html') # => String

Constants

VERSION

MAJOR version when you make incompatible API changes MINOR version when you add functionality in a backwards-compatible manner PATCH version when you make backwards-compatible bug fixes.

Public Class Methods

logger(shift_age: 'daily', datetime_format: '%Y-%m-%d %H:%M:%S', log_dir: 'logs' ) click to toggle source

UNKNOWN: An unknown message that should always be logged. FATAL: An unhandleable error that results in a program crash. ERROR: A handleable error condition. WARN: A warning. INFO: Generic (useful) information about system operation. DEBUG: Low-level information for developers.

# File lib/utter.rb, line 28
def self.logger(shift_age: 'daily',
                datetime_format: '%Y-%m-%d %H:%M:%S',
                log_dir: 'logs'
               )

  Dir.mkdir(log_dir) unless File.exists?(log_dir)
  logger_file = "#{log_dir}/#{DateTime.now.strftime('%m_%d_%Y')}.log"
  file = File.open(logger_file, File::WRONLY | File::APPEND | File::CREAT)

  @log = Logger.new("| tee " + file.path, shift_age)
  @log.datetime_format = datetime_format

  @log.info "Utter Log Levels: DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN"
  return @log
end