spec/child_logger_spec.rb in ougai-1.4.4 vs spec/child_logger_spec.rb in ougai-1.5.0
- old
+ new
@@ -30,23 +30,61 @@
}
describe '#level propagated from parent one' do
let(:logger) { parent_logger.child }
+ context 'TRACE' do
+ let(:log_msg) { 'log message' }
+ before { parent_logger.level = Ougai::Logger::TRACE }
+
+ it 'outputs trace message' do
+ logger.trace(log_msg)
+ expect(item).to be_log_message(log_msg, 10)
+ end
+
+ it 'outputs debug message' do
+ logger.debug(log_msg)
+ expect(item).to be_log_message(log_msg, 20)
+ end
+
+ it 'is consistent with the methods severity allows' do
+ expect(logger.trace?).to be_truthy
+ expect(logger.debug?).to be_truthy
+ expect(logger.info?).to be_truthy
+ expect(logger.warn?).to be_truthy
+ expect(logger.error?).to be_truthy
+ expect(logger.fatal?).to be_truthy
+ end
+ end
+
context 'DEBUG' do
let(:log_msg) { 'log message' }
before { parent_logger.level = Logger::DEBUG }
+ it 'does not output trace message' do
+ logger.trace(log_msg)
+ expect(item).to be_nil
+ end
+
it 'outputs debug message' do
logger.debug(log_msg)
expect(item).to be_log_message(log_msg, 20)
end
it 'outputs info message' do
logger.info(log_msg)
expect(item).to be_log_message(log_msg, 30)
end
+
+ it 'is consistent with the methods severity allows' do
+ expect(logger.trace?).to be_falsey
+ expect(logger.debug?).to be_truthy
+ expect(logger.info?).to be_truthy
+ expect(logger.warn?).to be_truthy
+ expect(logger.error?).to be_truthy
+ expect(logger.fatal?).to be_truthy
+ end
end
context 'INFO' do
let(:log_msg) { 'log message' }
before { parent_logger.level = Logger::INFO }
@@ -63,10 +101,19 @@
it 'outputs warning message' do
logger.warn(log_msg)
expect(item).to be_log_message(log_msg, 40)
end
+
+ it 'is consistent with the methods severity allows' do
+ expect(logger.trace?).to be_falsey
+ expect(logger.debug?).to be_falsey
+ expect(logger.info?).to be_truthy
+ expect(logger.warn?).to be_truthy
+ expect(logger.error?).to be_truthy
+ expect(logger.fatal?).to be_truthy
+ end
end
context 'WARN' do
let(:log_msg) { 'log message' }
before { parent_logger.level = Logger::WARN }
@@ -83,10 +130,19 @@
it 'outputs error message' do
logger.error(log_msg)
expect(item).to be_log_message(log_msg, 50)
end
+
+ it 'is consistent with the methods severity allows' do
+ expect(logger.trace?).to be_falsey
+ expect(logger.debug?).to be_falsey
+ expect(logger.info?).to be_falsey
+ expect(logger.warn?).to be_truthy
+ expect(logger.error?).to be_truthy
+ expect(logger.fatal?).to be_truthy
+ end
end
context 'ERROR' do
let(:log_msg) { 'log message' }
before { parent_logger.level = Logger::ERROR }
@@ -103,10 +159,19 @@
it 'outputs fatal message' do
logger.fatal(log_msg)
expect(item).to be_log_message(log_msg, 60)
end
+
+ it 'is consistent with the methods severity allows' do
+ expect(logger.trace?).to be_falsey
+ expect(logger.debug?).to be_falsey
+ expect(logger.info?).to be_falsey
+ expect(logger.warn?).to be_falsey
+ expect(logger.error?).to be_truthy
+ expect(logger.fatal?).to be_truthy
+ end
end
context 'FATAL' do
let(:log_msg) { 'log message' }
before { parent_logger.level = Logger::FATAL }
@@ -123,10 +188,19 @@
it 'outputs unknown message' do
logger.unknown(log_msg)
expect(item).to be_log_message(log_msg, 70)
end
+
+ it 'is consistent with the methods severity allows' do
+ expect(logger.trace?).to be_falsey
+ expect(logger.debug?).to be_falsey
+ expect(logger.info?).to be_falsey
+ expect(logger.warn?).to be_falsey
+ expect(logger.error?).to be_falsey
+ expect(logger.fatal?).to be_truthy
+ end
end
context 'UNKNOWN' do
let(:log_msg) { 'log message' }
before { parent_logger.level = Logger::UNKNOWN }
@@ -137,9 +211,18 @@
end
it 'outputs unknown message' do
logger.unknown(log_msg)
expect(item).to be_log_message(log_msg, 70)
+ end
+
+ it 'is consistent with the methods severity allows' do
+ expect(logger.trace?).to be_falsey
+ expect(logger.debug?).to be_falsey
+ expect(logger.info?).to be_falsey
+ expect(logger.warn?).to be_falsey
+ expect(logger.error?).to be_falsey
+ expect(logger.fatal?).to be_falsey
end
end
end
describe '#chain' do