Commit 3a83767f authored by Douwe Maan's avatar Douwe Maan

Merge branch 'logger-error' into 'master'

Add missing GitlabLogger#error method

Closes #130

See merge request gitlab-org/gitlab-shell!200
parents 69941f90 17f4731f
v7.1.2
- Add missing GitlabLogger#error method (!200)
v7.1.1
- Flush log file after every write (!199)
......
......@@ -20,7 +20,8 @@ class GitlabLogger
LEVELS = {
Logger::INFO => 'info'.freeze,
Logger::DEBUG => 'debug'.freeze,
Logger::WARN => 'warn'.freeze
Logger::WARN => 'warn'.freeze,
Logger::ERROR => 'error'.freeze
}.freeze
def initialize(level, path, log_format)
......@@ -47,6 +48,10 @@ class GitlabLogger
log_at(Logger::WARN, message, data)
end
def error(message, data = {})
log_at(Logger::ERROR, message, data)
end
private
attr_reader :log_file, :log_format
......
......@@ -38,6 +38,24 @@ describe GitlabLogger do
end
end
describe '#error' do
context 'when the log level is too high' do
let(:level) { Logger::FATAL }
it 'does nothing' do
subject.info('hello world')
expect(output.string).to eq('')
end
end
it 'logs data' do
subject.error('hello world', foo: 'bar')
expect(first_line).to eq('time="1973-11-29T21:33:09+00:00" level=error msg="hello world" foo=bar pid=1234')
end
end
describe '#info' do
context 'when the log level is too high' do
let(:level) { Logger::ERROR }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment