module Spyt
Spyt
Module: Root Module for Spyt
.
Spyt
Module
Spyt
Module
Spyt
Module
Spyt
Module
Spyt
Module
Constants
- CONFIG
Configuration: Defines Spyt's behavior.
- LEVELS
Levels: Available Log Levels, mapped to numeric values.
- LEVEL_COLS
Level Colors: When using Spiffup for colorization, this map defines which color corresponds to which level.
- VERSION
Version
Public Class Methods
method_missing(name, *args)
click to toggle source
Generic Log Handler: Route log calls to each level.
Calls superclass method
# File lib/spyt.rb, line 16 def self.method_missing name, *args # Fail on unknown Methods super unless LEVELS.include? name # Push Log (Level shortcuts) push name, args[0], args[1] end
push(lvl, src, msg)
click to toggle source
Push Message: Writes a message msg from src as level lvl to the log. @param [Symbol] lvl Log level (see LEVELS
) @param [String] src Message source @param [String] msg Message text
# File lib/spyt.rb, line 30 def self.push lvl, src, msg # Check Level raise "Invalid Log Level [#{lvl.to_s.inspect.bred}] requested" unless LEVELS.include? lvl.to_sym # Check Level return unless LEVELS[lvl] <= LEVELS[CONFIG[:lvl]] # Ensure Lock is available @lock ||= Mutex.new # Synchronize @lock.synchronize do # Write & Flush CONFIG[:out] << "#{Time.now.to_s.blue} [#{lvl.to_s.send LEVEL_COLS[lvl.to_sym]}] #{src.bmagenta} :: #{msg}\n" CONFIG[:out].flush if CONFIG[:out].respond_to? :flush end end