Module: Spectre::Logging

Defined in:
lib/spectre/logging.rb,
lib/spectre/logging/file.rb,
lib/spectre/logging/console.rb

Defined Under Namespace

Modules: Status Classes: Console, File, ModuleLogger

Constant Summary collapse

@@debug =
false
@@logger =
[]

Class Method Summary collapse

Class Method Details

.add(logger) ⇒ Object



62
63
64
# File 'lib/spectre/logging.rb', line 62

def add logger
  @@logger.append(logger)
end

.add_log(message, level, logger_name = 'spectre') ⇒ Object



161
162
163
164
165
# File 'lib/spectre/logging.rb', line 161

def add_log message, level, logger_name='spectre'
  return unless Spectre::Runner.current

  Spectre::Runner.current.log.append([DateTime.now, message, level, logger_name])
end

.debug!Object



54
55
56
# File 'lib/spectre/logging.rb', line 54

def debug!
  @@debug = true
end

.debug?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/spectre/logging.rb', line 58

def debug?
  @@debug
end

.end_context(context) ⇒ Object



78
79
80
# File 'lib/spectre/logging.rb', line 78

def end_context context
  delegate(:end_context, context)
end

.end_group(desc) ⇒ Object



122
123
124
# File 'lib/spectre/logging.rb', line 122

def end_group desc
  delegate(:end_group, desc)
end

.end_spec(spec, data = nil) ⇒ Object



86
87
88
# File 'lib/spectre/logging.rb', line 86

def end_spec spec, data=nil
  delegate(:end_spec, spec, data)
end

.end_subject(subject) ⇒ Object



70
71
72
# File 'lib/spectre/logging.rb', line 70

def end_subject subject
  delegate(:end_subject, subject)
end

.group(desc) ⇒ Object



155
156
157
158
159
# File 'lib/spectre/logging.rb', line 155

def group desc
  Spectre::Logging.start_group(desc)
  yield
  Spectre::Logging.end_group(desc)
end

.log_context(context) ⇒ Object



99
100
101
102
103
104
105
106
# File 'lib/spectre/logging.rb', line 99

def log_context context
  begin
    start_context(context)
    yield
  ensure
    end_context(context)
  end
end

.log_debug(message) ⇒ Object Also known as: debug



135
136
137
138
139
140
# File 'lib/spectre/logging.rb', line 135

def log_debug message
  return unless @@debug

  add_log(message, :debug)
  delegate(:log_debug, message)
end

.log_error(spec, exception) ⇒ Object



142
143
144
145
# File 'lib/spectre/logging.rb', line 142

def log_error spec, exception
  add_log(exception, :error)
  delegate(:log_error, spec, exception)
end

.log_info(message) ⇒ Object Also known as: info, log



130
131
132
133
# File 'lib/spectre/logging.rb', line 130

def log_info message
  add_log(message, :info)
  delegate(:log_info, message)
end

.log_process(desc) ⇒ Object



126
127
128
# File 'lib/spectre/logging.rb', line 126

def log_process desc
  delegate(:log_process, desc)
end

.log_separator(desc) ⇒ Object Also known as: separate



114
115
116
# File 'lib/spectre/logging.rb', line 114

def log_separator desc
  delegate(:log_separator, desc)
end

.log_skipped(spec, message = nil) ⇒ Object



147
148
149
# File 'lib/spectre/logging.rb', line 147

def log_skipped spec, message=nil
  delegate(:log_skipped, spec, message)
end

.log_spec(spec, data = nil) ⇒ Object



108
109
110
111
112
# File 'lib/spectre/logging.rb', line 108

def log_spec spec, data=nil
  start_spec(spec, data)
  yield
  end_spec(spec, data)
end

.log_status(desc, status, annotation = nil) ⇒ Object



151
152
153
# File 'lib/spectre/logging.rb', line 151

def log_status desc, status, annotation=nil
  delegate(:log_status, desc, status, annotation)
end

.log_subject(subject) ⇒ Object



90
91
92
93
94
95
96
97
# File 'lib/spectre/logging.rb', line 90

def log_subject subject
  begin
    start_subject(subject)
    yield
  ensure
    end_subject(subject)
  end
end

.start_context(context) ⇒ Object



74
75
76
# File 'lib/spectre/logging.rb', line 74

def start_context context
  delegate(:start_context, context)
end

.start_group(desc) ⇒ Object



118
119
120
# File 'lib/spectre/logging.rb', line 118

def start_group desc
  delegate(:start_group, desc)
end

.start_spec(spec, data = nil) ⇒ Object



82
83
84
# File 'lib/spectre/logging.rb', line 82

def start_spec spec, data=nil
  delegate(:start_spec, spec, data)
end

.start_subject(subject) ⇒ Object



66
67
68
# File 'lib/spectre/logging.rb', line 66

def start_subject subject
  delegate(:start_subject, subject)
end