File: logable.rb

package info (click to toggle)
ruby-directory-watcher 1.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 224 kB
  • ctags: 224
  • sloc: ruby: 1,411; makefile: 5
file content (26 lines) | stat: -rw-r--r-- 537 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class DirectoryWatcher

  # This is the implementation of a logger that does nothing.
  # It has all the debug, info, warn, error, fatal methods, but they do nothing
  class NullLogger
    def debug( msg ); end
    def info( msg );  end
    def warn( msg );  end
    def error( msg ); end
    def fatal( msg ); end
  end

  module Logable
    def logger
      @config.logger
    end

    def self.default_logger
      require 'logging'
      Logging::Logger[DirectoryWatcher]
    rescue LoadError
      NullLogger.new
    end
  end

end