Class: Logger::ColorFormatter

### Home Classes Methods

### In Files

- lib/innate/log/color_formatter.rb

### Parent

Formatter

### Methods

- ::color?
- #call
- #colorize
- #format_time

### Class/Module Index

Quicksearch

- Innate
- Innate::Action
- Innate::Adapter
- Innate::Cache
- Innate::Cache::API
- Innate::Cache::DRb
- Innate::Cache::FileBased
- Innate::Cache::Marshal
- Innate::Cache::Memory
- Innate::Cache::YAML
- Innate::Current
- Innate::Etanni
- Innate::Helper
- Innate::Helper::Aspect
- Innate::Helper::Aspect::SingletonMethods
- Innate::Helper::CGI
- Innate::Helper::Flash
- Innate::Helper::Link
- Innate::Helper::Redirect
- Innate::Helper::Render
- Innate::HelperAccess
- Innate::HelpersHelper
- Innate::LRUHash
- Innate::LogHub
- Innate::Mock
- Innate::Mock::Session
- Innate::Node
- Innate::Optioned
- Innate::Optioned::SingletonMethods
- Innate::Options
- Innate::Request
- Innate::Response
- Innate::Rewrite
- Innate::Route
- Innate::Session
- Innate::Session::Flash
- Innate::SingletonMethods
- Innate::StateAccessor
- Innate::Traited
- Innate::Trinity
- Innate::URLMap
- Innate::View
- Innate::View::ERB
- Innate::View::Etanni
- Innate::View::None
- Logger
- Logger::ColorFormatter
- Object

No matching classes.

# Logger::ColorFormatter

Extended Formatter that supports ANSI colors.

The basic mapping of ANSI colors is as follows:

        | reset | bold | dark | underline | blink | negative
    MOD |     0 |    1 |    2 |         4 |     5 |        7

       | black | red | green | yellow | blue | magenta | cyan | white
    FG |    30 |  31 |    32 |     33 |   34 |      35 |   36 |    37
    BG |    40 |  41 |    42 |     43 |   44 |      45 |   46 |    47

The output is done by: "e[#{mod};#{fg};#{bg}m#{string}e[0m". The suffix is to reset the terminal to the original state again.

### Constants

FORMAT_LINE
FORMAT_TIME
LEVEL_COLOR

### Public Class Methods

color?(logdev) click to toggle source

    # File lib/innate/log/color_formatter.rb, line 45
    def self.color?(logdev)
      logdev.respond_to?(:tty?) and logdev.tty?
    end

### Public Instance Methods

call(severity, time, program, message) click to toggle source

    # File lib/innate/log/color_formatter.rb, line 28
    def call(severity, time, program, message)
      hint = severity[0,1]
      time = format_time(time)
      pid = $$
      string = colorize(msg2str(message), severity)

      FORMAT_LINE % [hint, time, pid, severity, program, string]
    end

colorize(string, severity) click to toggle source

    # File lib/innate/log/color_formatter.rb, line 41
    def colorize(string, severity)
      LEVEL_COLOR[severity] % string
    end

format_time(time) click to toggle source

    # File lib/innate/log/color_formatter.rb, line 37
    def format_time(time)
      time.strftime(FORMAT_TIME)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.