indi.atlantis.framework.chaconne.JobLoggerAspect Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chaconne-spring-boot-starter Show documentation
Show all versions of chaconne-spring-boot-starter Show documentation
Distributed task scheduling application framework
The newest version!
/**
* Copyright 2017-2021 Fred Feng ([email protected])
* 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 indi.atlantis.framework.chaconne;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.Marker;
import com.github.paganini2008.devtools.collection.ListUtils;
import com.github.paganini2008.devtools.proxy.Aspect;
/**
*
* JobLoggerAspect
*
* @author Fred Feng
*
* @since 2.0.1
*/
public class JobLoggerAspect implements Aspect {
private static final List enhancedMethodNames = Collections
.unmodifiableList(Arrays.asList("trace", "debug", "info", "warn", "error"));
private final JobKey jobKey;
private final LogManager logManager;
JobLoggerAspect(JobKey jobKey, LogManager logManager) {
this.jobKey = jobKey;
this.logManager = logManager;
}
private long traceId;
public void setTraceId(long traceId) {
this.traceId = traceId;
}
@Override
public boolean afterCall(Object target, Method method, Object[] args) {
final Logger log = (Logger) target;
final String methodName = method.getName();
if (enhancedMethodNames.contains(methodName)) {
List