br.com.objectos.logger.AbstractConfigurableLogger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of objectos-logger Show documentation
Show all versions of objectos-logger Show documentation
Provides a Objectos Core Logging implementation.
The newest version!
/*
* Copyright (C) 2021 Objectos Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package br.com.objectos.logger;
import br.com.objectos.core.logging.Event;
import br.com.objectos.core.logging.Event0;
import br.com.objectos.core.logging.Event1;
import br.com.objectos.core.logging.Event2;
import br.com.objectos.core.logging.Event3;
import br.com.objectos.core.logging.Level;
import br.com.objectos.core.logging.Logger;
import br.com.objectos.core.object.Checks;
abstract class AbstractConfigurableLogger implements ConfigurableLogger {
Level level = Level.TRACE;
/**
* Returns the current level of this logger.
*
* @return the current level of this logger
*/
public final Level getLevel() {
return level;
}
/**
* {@inheritDoc}
*/
@Override
public final boolean isEnabled(Event event) {
if (event == null) {
return false;
}
return event.isEnabled(level);
}
/**
* {@inheritDoc}
*/
@Override
public final void log(Event0 event) {
if (event == null) {
return;
}
if (!event.isEnabled(level)) {
return;
}
write(
new WriteJobLog0(event)
);
}
/**
* {@inheritDoc}
*/
@Override
public final void log(Event1 event, T1 v1) {
if (event == null) {
return;
}
if (!event.isEnabled(level)) {
return;
}
write(
new WriteJobLog1(event, v1)
);
}
/**
* {@inheritDoc}
*/
@Override
public final void log(Event2 event, T1 v1, T2 v2) {
if (event == null) {
return;
}
if (!event.isEnabled(level)) {
return;
}
write(
new WriteJobLog2(event, v1, v2)
);
}
/**
* {@inheritDoc}
*/
@Override
public final void log(Event3 event, T1 v1, T2 v2, T3 v3) {
if (event == null) {
return;
}
if (!event.isEnabled(level)) {
return;
}
write(
new WriteJobLog3(event, v1, v2, v3)
);
}
@Override
public Logger replace(Logger logger) {
return logger;
}
/**
* {@inheritDoc}
*/
@Override
public final void setLevel(Level level) {
this.level = Checks.checkNotNull(level, "level == null");
}
abstract void write(WriteJobLog log);
}