howl.log
after_each ->
log.clear!
app.window = nil
is exported globally as `log`
assert.equal type(_G.log), 'table'
warn() is the same as warning()
assert.same log.warn, log.warning
(when howl.app.window is available and showing)
local method
before_each ->
method = spy.new -> true
app.window = visible: true, command_line: {}, status: [m]: method
after_each ->
app.window = nil
sends the message to howl.app.window.status\\' .. m .. '() if available
log[m] 'message'
assert.spy(method).was.called_with match.is_ref(app.window.status), 'message'
only propagates the first line of the message
log[m] 'message\nline2\nline3'
assert.spy(method).was.called_with match.is_ref(app.window.status), 'message'
removes any location info before propagating
log[m] '[string "../foo/bar.lua"]:32: juicy bit'
assert.spy(method).was.called_with match.is_ref(app.window.status), 'juicy bit'
(when howl.app.window is available and showing)
local method
before_each ->
method = spy.new -> true
app.window = visible: true, command_line: {}, status: [m]: method
after_each ->
app.window = nil
sends the message to howl.app.window.status\\' .. m .. '() if available
log[m] 'message'
assert.spy(method).was.called_with match.is_ref(app.window.status), 'message'
only propagates the first line of the message
log[m] 'message\nline2\nline3'
assert.spy(method).was.called_with match.is_ref(app.window.status), 'message'
removes any location info before propagating
log[m] '[string "../foo/bar.lua"]:32: juicy bit'
assert.spy(method).was.called_with match.is_ref(app.window.status), 'juicy bit'
(when howl.app.window is available and showing)
local method
before_each ->
method = spy.new -> true
app.window = visible: true, command_line: {}, status: [m]: method
after_each ->
app.window = nil
sends the message to howl.app.window.status\\' .. m .. '() if available
log[m] 'message'
assert.spy(method).was.called_with match.is_ref(app.window.status), 'message'
only propagates the first line of the message
log[m] 'message\nline2\nline3'
assert.spy(method).was.called_with match.is_ref(app.window.status), 'message'
removes any location info before propagating
log[m] '[string "../foo/bar.lua"]:32: juicy bit'
assert.spy(method).was.called_with match.is_ref(app.window.status), 'juicy bit'
book keeping
.entries is a list of the last log entries
log.error 'my error'
assert.equal #log.entries, 1
assert.same log.entries[1], {
essentials: 'my error'
message: 'my error'
level: 'error'
}
.last_error points to the last error logged
assert.is_nil log.last_error
log.error 'foo'
assert.equal 'foo', log.last_error.message
log.error 'bar'
assert.equal 'bar', log.last_error.message
defines a "max_log_entries" config variable, defaulting to 1000
assert.not_nil config.definitions.max_log_entries
assert.equal config.max_log_entries, 1000
retains at most <max_log_entries> of the last entries
config.max_log_entries = 1
for i = 1,10
log.error 'my error ' .. i
assert.equal #log.entries, 1
assert.same log.entries[1], {
essentials: 'my error 10'
message: 'my error 10'
level: 'error'
}
.clear() clears all log entries
log.error 'my error'
log.clear!
assert.equal #log.entries, 0
(when a message is logged)
local append, trim
log.clear!
before_each ->
append = spy.new -> true
trim = spy.new -> true
signal.connect 'log-entry-appended', append
signal.connect 'log-trimmed', trim
after_each ->
signal.disconnect 'log-entry-appended', append
signal.disconnect 'log-trimmed', trim
log.clear!
append = nil
trim = nil
emits append signals
log.info 'test'
assert.spy(append).was.called_with
essentials: 'test'
level: 'info'
message: 'test'
emits trim signals
log.info 'info'
log.clear!
assert.spy(trim).was.called_with
size: 0