Module: RTSP::Global

Included in:
Helpers, Request, Server, SocatStreaming
Defined in:
lib/rtsp/global.rb

Constant Summary collapse

DEFAULT_RTSP_PORT =
554
DEFAULT_VERSION =
'1.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#log(message, level = log_level) ⇒ Object

Parameters:

  • message (String)

    The string to log.



38
39
40
# File 'lib/rtsp/global.rb', line 38

def log(message, level=log_level)
  logger.send(level, message) if log?
end

#log_levelSymbol

The Logger method to use for logging all messages.

Returns:

  • (Symbol)

    Defaults to :debug.



33
34
35
# File 'lib/rtsp/global.rb', line 33

def log_level
  @log_level ||= :debug
end

#loggerLogger

By default, this creates a standard Ruby Logger. If a different type was passed in via #logger=, this returns that object.

Returns:



23
24
25
# File 'lib/rtsp/global.rb', line 23

def logger
  @logger ||= ::Logger.new STDOUT
end

#raise_errors=(value) ⇒ Object (writeonly)

Use to disable the raising of RTSP::Errors.



43
44
45
# File 'lib/rtsp/global.rb', line 43

def raise_errors=(value)
  @raise_errors = value
end

Instance Method Details

#log?Boolean

Returns true if logging is enabled; false if it’s turned off.

Returns:

  • (Boolean)

    true if logging is enabled; false if it’s turned off.



12
13
14
# File 'lib/rtsp/global.rb', line 12

def log?
  @log != false
end

#raise_errors?Boolean

Returns true if set to raise errors; false if not.

Returns:

  • (Boolean)

    true if set to raise errors; false if not.



46
47
48
# File 'lib/rtsp/global.rb', line 46

def raise_errors?
  @raise_errors != false
end

#reset_config!Object

Resets class variables back to defaults.



56
57
58
59
60
61
# File 'lib/rtsp/global.rb', line 56

def reset_config!
  self.log = true
  self.logger = ::Logger.new STDOUT
  self.log_level = :debug
  self.raise_errors = true
end

#rtsp_versionString

Returns The RTSP version.

Returns:

  • (String)

    The RTSP version.



51
52
53
# File 'lib/rtsp/global.rb', line 51

def rtsp_version
  @version ||= DEFAULT_VERSION
end