Class: Innate::LogHub

### Home Classes Methods

### In Files

- lib/innate/log/hub.rb

### Parent

Object

### Methods

- ::new
- #level=
- #method_missing
- #start
- #stop
- #write

### Included Modules

- Logger::Severity
- Innate::Optioned

### 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.

# Innate::LogHub

Innate only provides logging via stdlib Logger to avoid bloat and dependencies, you may specify multiple loggers in the Log instance of LogHub to accomendate your needs, by default we log to $stderr to be compatible with CGI.

Please read the documentation of logger.rb (or even better, its source) to get a feeling of how to use it correctly within Innate

A few shortcuts:

1. Create logger for stderr/stdout

       logger = Logger.new($stdout)
       logger = Logger.new($stderr)

2. Create logger for a file

       logger = Logger.new('test.log')

3. Create logger for file object

       file = File.open('test.log', 'a+')
       logger = Logger.new(file)

4. Create logger with rotation on specified file size

       # 10 files history, 5 MB each
       logger = Logger.new('test.log', 10, (5 << 20))

       # 100 files history, 1 MB each
       logger = Logger.new('test.log', 100, (1 << 20))

5. Create a logger which ages logfiles daily/weekly/monthly

       logger = Logger.new('test.log', 'daily')
       logger = Logger.new('test.log', 'weekly')
       logger = Logger.new('test.log', 'monthly')

### Attributes

active[RW]
loggers[RW]
program[RW]

### Public Class Methods

new(*loggers) click to toggle source

`loggers` should be a list of Logger instances

    # File lib/innate/log/hub.rb, line 46
    def initialize(*loggers)
      @loggers = loggers.flatten
      @program = nil
      @active = true
      self.level = DEBUG
    end

### Public Instance Methods

level=(lvl) click to toggle source

set level for all loggers

    # File lib/innate/log/hub.rb, line 54
    def level=(lvl)
      @loggers.each{|l| l.level = lvl }
      @level = lvl
    end

method_missing(meth, *args, &block) click to toggle source

    # File lib/innate/log/hub.rb, line 62
    def method_missing(meth, *args, &block)
      eval %
        def #{meth}(*args, &block)
          return unless @active
          args.each{|arg| @loggers.each{|logger| logger.#{meth}(arg, &block) }}
        end
      ~

      send(meth, *args, &block)
    end

start() click to toggle source

    # File lib/innate/log/hub.rb, line 59
    def start; @active = true;  end

stop() click to toggle source

    # File lib/innate/log/hub.rb, line 60
    def stop;  @active = false; end

write(*args) click to toggle source

    # File lib/innate/log/hub.rb, line 73
    def write(*args)
      self.<<(*args)
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.