Skip to content
This repository was archived by the owner on May 27, 2020. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

$ gem install log4r-xmpp

The following gems are required to use Log4r-XMPP:

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

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.

: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
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"

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

---
# *** 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
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"

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

About

XMPP Outputter for Log4r

Resources

Stars

6 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages