Module: Errlog::Constants

Included in:
Errlog, Errlog
Defined in:
lib/errlog/constants.rb

Overview

This module could be extended for easy access to constants and severity test helpers

severity constants collapse

ERROR =
100
WARNING =
50
NOT_FOUND =
49
TRACE =
1
STAT_DATA =
1001

Instance Method Summary collapse

Instance Method Details

#is_error?(code) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/errlog/constants.rb', line 17

def is_error?(code)
  code >= ERROR
end

#is_trace?(code) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/errlog/constants.rb', line 25

def is_trace? code
  code >= TRACE && code < WARNING
end

#is_warning?(code) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/errlog/constants.rb', line 21

def is_warning? code
  code >= WARNING && code < ERROR
end

#severity_name(code) ⇒ String

Returns name of the corresponding severity code.

Returns:

  • (String)

    name of the corresponding severity code



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/errlog/constants.rb', line 30

def severity_name code
  case code
    when NOT_FOUND;
      'not found'
    when TRACE...WARNING;
      'trace'
    when WARNING...ERROR;
      'warning'
    else
      ; 'error'
  end
end