summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer (GitLab) <jacob@gitlab.com>2018-04-09 12:05:28 +0000
committerDouwe Maan <douwe@gitlab.com>2018-04-09 12:05:28 +0000
commit17f4731fcf5c38185cdc8aab450d708c0618aa2f (patch)
tree516bad39079225dc0f16f2f45e03ff381ce2fdd4
parent69941f9075b64e8ed518a33e87b00c52169f4dbf (diff)
downloadgitlab-shell-17f4731fcf5c38185cdc8aab450d708c0618aa2f.tar.gz
Add missing GitlabLogger#error method
-rw-r--r--CHANGELOG3
-rw-r--r--VERSION2
-rw-r--r--lib/gitlab_logger.rb7
-rw-r--r--spec/gitlab_logger_spec.rb18
4 files changed, 28 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index d9937f7..388c478 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+v7.1.2
+ - Add missing GitlabLogger#error method (!200)
+
v7.1.1
- Flush log file after every write (!199)
diff --git a/VERSION b/VERSION
index 21c8c7b..a8a1887 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-7.1.1
+7.1.2
diff --git a/lib/gitlab_logger.rb b/lib/gitlab_logger.rb
index f81c2f6..ed169f7 100644
--- a/lib/gitlab_logger.rb
+++ b/lib/gitlab_logger.rb
@@ -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
diff --git a/spec/gitlab_logger_spec.rb b/spec/gitlab_logger_spec.rb
index eec6648..934b6fa 100644
--- a/spec/gitlab_logger_spec.rb
+++ b/spec/gitlab_logger_spec.rb
@@ -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 }