Class: MCollective::Logger::Console_logger

### Home Classes Methods

### In Files

- lib/mcollective/logger/console_logger.rb

### Parent

Base

### Methods

- #color
- #colorize
- #log
- #set_logging_level
- #start
- #valid_levels

### Files

- COPYING
- README
- Rakefile
- PLACEHOLDER
- PLACEHOLDER

### Class/Module Index

Quicksearch

- MCollective
- MCollective::Agent
- MCollective::Agents
- MCollective::Aggregate
- MCollective::Aggregate::Base
- MCollective::Aggregate::Result
- MCollective::Aggregate::Result::Base
- MCollective::Aggregate::Result::CollectionResult
- MCollective::Aggregate::Result::NumericResult
- MCollective::Application
- MCollective::Applications
- MCollective::Client
- MCollective::Config
- MCollective::Connector
- MCollective::Connector::Base
- MCollective::DDL
- MCollective::DDLValidationError
- MCollective::Data
- MCollective::Data::Base
- MCollective::Data::Result
- MCollective::Discovery
- MCollective::Facts
- MCollective::Facts::Base
- MCollective::Generators
- MCollective::Generators::AgentGenerator
- MCollective::Generators::Base
- MCollective::Generators::DataGenerator
- MCollective::InvalidRPCData
- MCollective::Log
- MCollective::Logger
- MCollective::Logger::Base
- MCollective::Logger::Console_logger
- MCollective::Logger::File_logger
- MCollective::Logger::Syslog_logger
- MCollective::Matcher
- MCollective::Matcher::Parser
- MCollective::Matcher::Scanner
- MCollective::Message
- MCollective::MissingRPCData
- MCollective::MsgDoesNotMatchRequestID
- MCollective::MsgTTLExpired
- MCollective::NotTargettedAtUs
- MCollective::Optionparser
- MCollective::PluginManager
- MCollective::PluginPackager
- MCollective::PluginPackager::AgentDefinition
- MCollective::PluginPackager::StandardDefinition
- MCollective::RPC
- MCollective::RPC::ActionRunner
- MCollective::RPC::Agent
- MCollective::RPC::Audit
- MCollective::RPC::Client
- MCollective::RPC::Helpers
- MCollective::RPC::Progress
- MCollective::RPC::Reply
- MCollective::RPC::Request
- MCollective::RPC::Result
- MCollective::RPC::Stats
- MCollective::RPCAborted
- MCollective::RPCError
- MCollective::Registration
- MCollective::Registration::Base
- MCollective::Runner
- MCollective::RunnerStats
- MCollective::SSL
- MCollective::Security
- MCollective::Security::Base
- MCollective::SecurityValidationFailed
- MCollective::Shell
- MCollective::UnixDaemon
- MCollective::UnknownRPCAction
- MCollective::UnknownRPCError
- MCollective::Util
- MCollective::WindowsDaemon
- Array
- Dir
- Object
- String
- Symbol

No matching classes.

# MCollective::Logger::Console_logger

Implements a syslog based logger using the standard ruby syslog class

### Public Instance Methods

color(level) click to toggle source

Set some colors for various logging levels, will honor the color configuration option and return nothing if its configured not to

    # File lib/mcollective/logger/console_logger.rb, line 39
    def color(level)
      colorize = Config.instance.color

      colors = {:error => Util.color(:red),
                :fatal => Util.color(:red),
                :warn  => Util.color(:yellow),
                :info  => Util.color(:green),
                :reset => Util.color(:reset)}

      if colorize
        return colors[level] || ""
      else
        return ""
      end
    end

colorize(level, msg) click to toggle source

Helper to return a string in specific color

    # File lib/mcollective/logger/console_logger.rb, line 56
    def colorize(level, msg)
      "%s%s%s" % [ color(level), msg, color(:reset) ]
    end

log(level, from, msg, normal_output=STDERR, last_resort_output=STDERR) click to toggle source

    # File lib/mcollective/logger/console_logger.rb, line 24
    def log(level, from, msg, normal_output=STDERR, last_resort_output=STDERR)
      if @known_levels.index(level) >= @known_levels.index(@active_level)
        time = Time.new.strftime("%Y/%m/%d %H:%M:%S")

        normal_output.puts("%s %s: %s %s" % [colorize(level, level), time, from, msg])
      end
    rescue
      # if this fails we probably cant show the user output at all,
      # STDERR it as last resort
      last_resort_output.puts("#{level}: #{msg}")
    end

set_logging_level(level) click to toggle source

    # File lib/mcollective/logger/console_logger.rb, line 12
    def set_logging_level(level)
      # nothing to do here, we ignore high levels when we log
    end

start() click to toggle source

    # File lib/mcollective/logger/console_logger.rb, line 5
    def start
      set_level(:info)

      config = Config.instance
      set_level(config.loglevel.to_sym) if config.configured
    end

valid_levels() click to toggle source

    # File lib/mcollective/logger/console_logger.rb, line 16
    def valid_levels
      {:info  => :info,
       :warn  => :warning,
       :debug => :debug,
       :fatal => :crit,
       :error => :err}
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.