Project

log4r-xmpp

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Add XMPP/Jabber functionality to Log4r
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

>= 0
>= 0
 Project Readme

Log4r-XMPP¶ ↑

Description¶ ↑

Log4r-XMPP adds a XMPP/Jabber outputter to Log4r.

Installation¶ ↑

$ gem install log4r-xmpp

Requirements¶ ↑

The following gems are required to use Log4r-XMPP:

Caveats¶ ↑

  • Do NOT include Log4r into your namespace! XMPP4r uses the generic Logger library and would become present in your namespace.

Using Log4r-XMPP¶ ↑

Requiring ‘log4r-xmpp’ will add an XMPPOutputter to Log4r. It is as simple as using any other Log4r::Outputter and can use most formatters in addition to the default.

Options:¶ ↑

:buffsize   => The number of logging events to buffer before sending (default 1)
:username   => Sending user's XMPP/Jabber account username
:password   => Sending user's XMPP/Jabber account password
:resource   => Optional sending user's XMPP/Jabber resource (default 'Log4r')
:recipients => An array of accounts to send Log4r log statements to

Example:¶ ↑

require 'log4r-xmpp'

options = { :buffsize   => 10,
            :username   => 'log4r@example.com',
            :password   => 'secret',
            :resource   => 'Log4r',
            :recipients => ['recipient1@example.com', 'recipient2@example.com']
          }

outputter = Log4r::XMPPOutputter.new('xmpp', options)

mylog = Log4r::Logger.new 'mylog'
mylog.outputters = outputter

mylog.debug "This is a test message sent at level DEBUG"

Using Log4r-XMPP with Log4r::YamlConfigurator¶ ↑

Requiring ‘log4r-xmpp/yamlconfigurator’ will patch Log4r::YamlConfigurator to accept an array list of recipients. Substitutions are still taken into consideration.

Example YAML:¶ ↑

---
# *** YAML2LOG4R ***
log4r_config:
  # define all loggers ...
  loggers:
    - name      : mylog
      level     : DEBUG
      trace     : 'false'
      outputters:
        - xmpp

  # define all outputters (incl. formatters)
  outputters:
    - type        : XMPPOutputter
      name        : 'xmpp'
      buffsize    : '10'
      username    : 'log4r@localhost'
      password    : 'secret'
      resource    : "#{RESOURCE}"
      recipients  : ["user1@#{DOMAIN}", "user2@#{DOMAIN}"]
      formatter   :
        date_pattern: '%y%m%d %H:%M:%S'
        pattern     : '%d %l: %m'
        type        : PatternFormatter

Example Loading:¶ ↑

require 'log4r-xmpp'
require 'log4r-xmpp/yamlconfigurator'

path = File.dirname(__FILE__)

Log4r::YamlConfigurator['RESOURCE'] = 'Log4r-XMPP'
Log4r::YamlConfigurator['DOMAIN']   = 'localhost'

Log4r::YamlConfigurator.load_yaml_file("#{path}/log4r-xmpp.yaml")

mylog = Log4r::Logger['mylog']

mylog.debug "This is a test message sent at level DEBUG"

Troubleshooting¶ ↑

XMPP4r’s logger facility logs to an internal logger named ‘xmpp4r’. Attach an outputter to view additional warning information.