File: logger.rb

package info (click to toggle)
ruby-dbus 0.16.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 520 kB
  • sloc: ruby: 3,786; sh: 53; makefile: 8
file content (31 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (3)
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
27
28
29
30
31
# dbus/logger.rb - debug logging
#
# This file is part of the ruby-dbus project
# Copyright (C) 2012 Martin Vidner
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License, version 2.1 as published by the Free Software Foundation.
# See the file "COPYING" for the exact licensing terms.

require "logger"

module DBus
  # Get the logger for the DBus module.
  # The default one logs to STDERR,
  # with DEBUG if $DEBUG is set, otherwise INFO.
  def logger
    unless defined? @logger
      @logger = Logger.new(STDERR)
      @logger.level = $DEBUG ? Logger::DEBUG : Logger::INFO
    end
    @logger
  end
  module_function :logger

  # Set the logger for the DBus module
  def logger=(logger)
    @logger = logger
  end
  module_function :logger=
end