Class: Slogger

### Home Classes Methods

### In Files

- examples/slogger.rb

### Parent

Object

### Methods

- ::new
- #on_abort
- #on_ack
- #on_begin
- #on_commit
- #on_connected
- #on_connectfail
- #on_connecting
- #on_disconnect
- #on_hbfire
- #on_hbread_fail
- #on_hbwrite_fail
- #on_miscerr
- #on_nack
- #on_publish
- #on_receive
- #on_ssl_connected
- #on_ssl_connectfail
- #on_ssl_connecting
- #on_subscribe
- #on_unsubscribe

### Files

- CHANGELOG.rdoc
- LICENSE

### Class/Module Index

Quicksearch

- Stomp
- Stomp::Client
- Stomp::Connection
- Stomp::Error
- Stomp::Error::ConnectReadTimeout
- Stomp::Error::DuplicateSubscription
- Stomp::Error::InvalidFormat
- Stomp::Error::InvalidHeartBeatHeaderError
- Stomp::Error::InvalidMessageLength
- Stomp::Error::InvalidServerCommand
- Stomp::Error::LoggerConnectionError
- Stomp::Error::MalformedFailoverOptionsError
- Stomp::Error::MaxReconnectAttempts
- Stomp::Error::MessageIDRequiredError
- Stomp::Error::NilMessageError
- Stomp::Error::NoCurrentConnection
- Stomp::Error::PacketParsingTimeout
- Stomp::Error::ProtocolError11p
- Stomp::Error::ProtocolErrorConnect
- Stomp::Error::SSLClientParamsError
- Stomp::Error::SSLNoCertFileError
- Stomp::Error::SSLNoKeyFileError
- Stomp::Error::SSLNoTruststoreFileError
- Stomp::Error::SSLUnreadableCertFileError
- Stomp::Error::SSLUnreadableKeyFileError
- Stomp::Error::SSLUnreadableTruststoreFileError
- Stomp::Error::SocketOpenTimeout
- Stomp::Error::StompServerError
- Stomp::Error::SubscriptionRequiredError
- Stomp::Error::UTF8ValidationError
- Stomp::Error::UnsupportedProtocolError
- Stomp::HeaderCodec
- Stomp::Message
- Stomp::SSLParams
- Client11Example1
- Client11PutGet1
- Connection11Example1
- Connection11Example2
- ExampleConsumer
- ExamplePublisher
- ExampleRubyCiphers
- ExampleSSL1
- ExampleSSL1C
- ExampleSSL2
- ExampleSSL2C
- ExampleSSL3
- ExampleSSL3C
- ExampleSSL4
- ExampleSSL4C
- ExampleTopicConsumer
- ExampleTopicPublisher
- Hash
- HeartBeatExample1
- LoggerExample
- Object
- Publish11Example1
- Receive11Example1
- Receive11Example2
- RepeatedHeadersExample
- SSLLoggerExample
- Slogger
- Stomp11Common
- TestBase
- TestClient
- TestConnection
- TestConnection1P
- TestMessage
- TestSSL
- TestURLLogins
- Tlogger

No matching classes.

# Slogger

## Example STOMP call back logger class.

Optional callback methods:

- on_connecting: connection starting

- on_connected: successful connect

- on_connectfail: unsuccessful connect (will usually be retried)

- on_disconnect: successful disconnect

- on_miscerr: on miscellaneous xmit/recv errors

- on_publish: publish called

- on_subscribe: subscribe called

- on_unsubscribe: unsubscribe called

- on_begin: begin called

- on_ack: ack called

- on_nack: nack called

- on_commit: commit called

- on_abort: abort called

- on_receive: receive called and successful

- on_ssl_connecting: SSL connection starting

- on_ssl_connected: successful SSL connect

- on_ssl_connectfail: unsuccessful SSL connect (will usually be retried)

- on_hbread_fail: unsuccessful Heartbeat read

- on_hbwrite_fail: unsuccessful Heartbeat write

- on_hbfire: on any send or receive heartbeat

All methods are optional, at the user's requirements.

If a method is not provided, it is not called (of course.)

IMPORTANT NOTE: in general, call back logging methods SHOULD not raise exceptions, otherwise the underlying STOMP connection may fail in mysterious ways.

There are two useful exceptions to this rule for:

- on_connectfail

- on_ssl_connectfail

These two methods can raise a Stomp::Errors::LoggerConnectionError. If this exception is raised, it is passed up the chain to the caller.

Callback parameters: are a copy of the @parameters instance variable for the Stomp::Connection.

### Public Class Methods

new(init_parms = nil) click to toggle source

Initialize a new callback logger instance.

    # File examples/slogger.rb, line 56
    def initialize(init_parms = nil)
      @log = Logger::new(STDOUT)          # User preference
      @log.level = Logger::DEBUG          # User preference
      @log.info("Logger initialization complete.")
    end

### Public Instance Methods

on_abort(parms, headers) click to toggle source

Log Abort

    # File examples/slogger.rb, line 195
    def on_abort(parms, headers)
      begin
        @log.debug "Abort Parms #{info(parms)}"
        @log.debug "Abort Result #{headers}"
      rescue
        @log.debug "Abort oops"
      end
    end

on_ack(parms, headers) click to toggle source

Log Ack

    # File examples/slogger.rb, line 165
    def on_ack(parms, headers)
      begin
        @log.debug "Ack Parms #{info(parms)}"
        @log.debug "Ack Result #{headers}"
      rescue
        @log.debug "Ack oops"
      end
    end

on_begin(parms, headers) click to toggle source

Log Begin

    # File examples/slogger.rb, line 155
    def on_begin(parms, headers)
      begin
        @log.debug "Begin Parms #{info(parms)}"
        @log.debug "Begin Result #{headers}"
      rescue
        @log.debug "Begin oops"
      end
    end

on_commit(parms, headers) click to toggle source

Log Commit

    # File examples/slogger.rb, line 185
    def on_commit(parms, headers)
      begin
        @log.debug "Commit Parms #{info(parms)}"
        @log.debug "Commit Result #{headers}"
      rescue
        @log.debug "Commit oops"
      end
    end

on_connected(parms) click to toggle source

Log connected events

    # File examples/slogger.rb, line 72
    def on_connected(parms)
      begin
        @log.debug "Connected: #{info(parms)}"
      rescue
        @log.debug "Connected oops"
      end
    end

on_connectfail(parms) click to toggle source

Log connectfail events

    # File examples/slogger.rb, line 81
      def on_connectfail(parms)
        begin
          @log.debug "Connect Fail #{info(parms)}"
        rescue
          @log.debug "Connect Fail oops"
        end
        # An example LoggerConnectionError raise
        @log.debug "Connect Fail, will raise"
        raise Stomp::Error::LoggerConnectionError.new("quit from connect fail")
      end

on_connecting(parms) click to toggle source

Log connecting events

    # File examples/slogger.rb, line 63
    def on_connecting(parms)
      begin
        @log.debug "Connecting: #{info(parms)}"
      rescue
        @log.debug "Connecting oops"
      end
    end

on_disconnect(parms) click to toggle source

Log disconnect events

    # File examples/slogger.rb, line 95
    def on_disconnect(parms)
      begin
        @log.debug "Disconnected #{info(parms)}"
      rescue
        @log.debug "Disconnected oops"
      end
    end

on_hbfire(parms, srind, firedata = {}) click to toggle source

Log heart beat fires

    # File examples/slogger.rb, line 258
    def on_hbfire(parms, srind, firedata = {})
      begin
        @log.debug "HeartBeat Fire Parms #{info(parms)}"
        @log.debug "HeartBeat Fire Send/Receive #{srind}"
      rescue
        @log.debug "HeartBeat Fire oops"
      end
    end

on_hbread_fail(parms, ticker_data = {}) click to toggle source

Stomp 1.1+ - heart beat read (receive) failed.

    # File examples/slogger.rb, line 205
    def on_hbread_fail(parms, ticker_data = {})
      begin
        @log.debug "Hbreadf Parms #{info(parms)}"
        @log.debug "Hbreadf Result #{ticker_data.inspect}"
      rescue
        @log.debug "Hbreadf oops"
      end
    end

on_hbwrite_fail(parms, ticker_data = {}) click to toggle source

Stomp 1.1+ - heart beat send (transmit) failed.

    # File examples/slogger.rb, line 215
    def on_hbwrite_fail(parms, ticker_data = {})
      begin
        @log.debug "Hbwritef Parms #{info(parms)}"
        @log.debug "Hbwritef Result #{ticker_data.inspect}"
      rescue
        @log.debug "Hbwritef oops"
      end
    end

on_miscerr(parms, errstr) click to toggle source

Log miscellaneous errors

    # File examples/slogger.rb, line 104
    def on_miscerr(parms, errstr)
      begin
        @log.debug "Miscellaneous Error #{info(parms)}"
        @log.debug "Miscellaneous Error String #{errstr}"
      rescue
        @log.debug "Miscellaneous Error oops"
      end
    end

on_nack(parms, headers) click to toggle source

Log NAck

    # File examples/slogger.rb, line 175
    def on_nack(parms, headers)
      begin
        @log.debug "NAck Parms #{info(parms)}"
        @log.debug "NAck Result #{headers}"
      rescue
        @log.debug "NAck oops"
      end
    end

on_publish(parms, message, headers) click to toggle source

Log Publish

    # File examples/slogger.rb, line 134
    def on_publish(parms, message, headers)
      begin
        @log.debug "Publish Parms #{info(parms)}"
        @log.debug "Publish Message #{message}"
        @log.debug "Publish Headers #{headers}"
      rescue
        @log.debug "Publish oops"
      end
    end

on_receive(parms, result) click to toggle source

Log Receive

    # File examples/slogger.rb, line 145
    def on_receive(parms, result)
      begin
        @log.debug "Receive Parms #{info(parms)}"
        @log.debug "Receive Result #{result}"
      rescue
        @log.debug "Receive oops"
      end
    end

on_ssl_connected(parms) click to toggle source

Log a successful SSL connect.

    # File examples/slogger.rb, line 234
    def on_ssl_connected(parms)
      begin
        @log.debug "SSL Connected Parms #{info(parms)}"
      rescue
        @log.debug "SSL Connected oops"
      end
    end

on_ssl_connectfail(parms) click to toggle source

Log an unsuccessful SSL connect.

    # File examples/slogger.rb, line 243
      def on_ssl_connectfail(parms)
        begin
          @log.debug "SSL Connect Fail Parms #{info(parms)}"
          @log.debug "SSL Connect Fail Exception #{parms[:ssl_exception]}, #{parms[:ssl_exception].message}"
        rescue
          @log.debug "SSL Connect Fail oops"
        end
        # An example LoggerConnectionError raise
        @log.debug "SSL Connect Fail, will raise"
        raise Stomp::Error::LoggerConnectionError.new("quit from SSL connect")
      end

on_ssl_connecting(parms) click to toggle source

Log SSL connection start.

    # File examples/slogger.rb, line 225
    def on_ssl_connecting(parms)
      begin
        @log.debug "SSL Connecting Parms #{info(parms)}"
      rescue
        @log.debug "SSL Connecting oops"
      end
    end

on_subscribe(parms, headers) click to toggle source

Log Subscribe

    # File examples/slogger.rb, line 114
    def on_subscribe(parms, headers)
      begin
        @log.debug "Subscribe Parms #{info(parms)}"
        @log.debug "Subscribe Headers #{headers}"
      rescue
        @log.debug "Subscribe oops"
      end
    end

on_unsubscribe(parms, headers) click to toggle source

Log UnSubscribe

    # File examples/slogger.rb, line 124
    def on_unsubscribe(parms, headers)
      begin
        @log.debug "UnSubscribe Parms #{info(parms)}"
        @log.debug "UnSubscribe Headers #{headers}"
      rescue
        @log.debug "UnSubscribe oops"
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.