Sha256: 12a578550fcbf2485cd9fb7c35e7fecf06c878de8ce95905257c56bd62bc7b67
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
# Author:: Eric Crane (mailto:eric.crane@mac.com) # Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved. # # Application Logging wrapper. # require 'active_support' module GlooLang module App class Log attr_accessor :quiet attr_reader :logger # # Set up a logger. # If quiet is true, then message are written to the log # but not to the console. # def initialize( engine, quiet=true ) @engine = engine f = File.join( @engine.settings.log_path, 'gloo.log' ) @logger = Logger.new( f ) @logger.level = Logger::DEBUG @quite = quiet end # # Show a message unless we're in quite mode. # def show( msg ) puts msg unless @quiet end # # Write a debug message to the log. # def debug( msg ) @logger.debug msg end # # Write an information message to the log. # Also write to the console unless quiet. # def info( msg ) @logger.info msg puts msg unless @quiet end # # Write a warning message to the log. # Also write to the console unless quiet. # def warn( msg ) @logger.warn msg puts msg unless @quiet end # # Write an error message to the log and set the error # in the engine's data heap. # Also write to the console unless quiet. # def error( msg, ex = nil, engine = nil ) engine&.heap&.error&.set_to msg @logger.error msg if ex @logger.error ex.message @logger.error ex.backtrace puts msg unless @quiet puts ex.message unless @quiet puts ex.backtrace unless @quiet else puts msg unless @quiet end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gloo-lang-0.9.11 | lib/gloo_lang/app/log.rb |
gloo-lang-0.9.10 | lib/gloo_lang/app/log.rb |
gloo-lang-0.9.9 | lib/gloo_lang/app/log.rb |