Skip to content

Commit 5894a61

Browse files
committed
switch to sl4j annotation
1 parent 7749cca commit 5894a61

File tree

71 files changed

+178
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+178
-260
lines changed

core/src/main/java/com/flowci/core/Application.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package com.flowci.core;
1818

1919
import com.flowci.util.StringHelper;
20-
import lombok.extern.log4j.Log4j2;
20+
import lombok.extern.slf4j.Slf4j;
2121
import org.springframework.beans.factory.annotation.Autowired;
2222
import org.springframework.boot.SpringApplication;
2323
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -31,7 +31,7 @@
3131
/**
3232
* @author yang
3333
*/
34-
@Log4j2
34+
@Slf4j
3535
@SpringBootApplication
3636
public class Application {
3737

core/src/main/java/com/flowci/core/agent/consumer/OnAgentCreated.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.flowci.core.agent.consumer;
22

3+
import com.flowci.core.agent.domain.Agent;
34
import com.flowci.core.agent.event.AgentCreatedEvent;
45
import com.flowci.core.common.domain.PushEvent;
56
import com.flowci.core.common.manager.SocketPushManager;
6-
import com.flowci.core.agent.domain.Agent;
7-
import lombok.extern.log4j.Log4j2;
7+
import lombok.extern.slf4j.Slf4j;
88
import org.springframework.beans.factory.annotation.Autowired;
99
import org.springframework.context.ApplicationListener;
1010
import org.springframework.stereotype.Component;
1111

12-
@Log4j2
12+
@Slf4j
1313
@Component
1414
public class OnAgentCreated implements ApplicationListener<AgentCreatedEvent> {
1515

core/src/main/java/com/flowci/core/agent/consumer/OnAgentHostStatusChange.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
import com.flowci.core.agent.event.AgentHostStatusEvent;
44
import com.flowci.core.common.domain.PushEvent;
55
import com.flowci.core.common.manager.SocketPushManager;
6-
import lombok.extern.log4j.Log4j2;
6+
import lombok.extern.slf4j.Slf4j;
77
import org.springframework.beans.factory.annotation.Autowired;
88
import org.springframework.context.ApplicationListener;
99
import org.springframework.stereotype.Component;
1010

11-
@Log4j2
11+
@Slf4j
1212
@Component
1313
public class OnAgentHostStatusChange implements ApplicationListener<AgentHostStatusEvent> {
1414

core/src/main/java/com/flowci/core/agent/consumer/OnAgentStatusChange.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616

1717
package com.flowci.core.agent.consumer;
1818

19+
import com.flowci.core.agent.domain.Agent;
1920
import com.flowci.core.agent.event.AgentStatusEvent;
2021
import com.flowci.core.common.domain.PushEvent;
2122
import com.flowci.core.common.manager.SocketPushManager;
22-
import com.flowci.core.agent.domain.Agent;
23-
import lombok.extern.log4j.Log4j2;
23+
import lombok.extern.slf4j.Slf4j;
2424
import org.springframework.beans.factory.annotation.Autowired;
2525
import org.springframework.context.ApplicationListener;
2626
import org.springframework.stereotype.Component;
2727

2828
/**
2929
* @author yang
3030
*/
31-
@Log4j2
31+
@Slf4j
3232
@Component
3333
public class OnAgentStatusChange implements ApplicationListener<AgentStatusEvent> {
3434

core/src/main/java/com/flowci/core/agent/controller/AgentController.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import com.flowci.core.agent.domain.DeleteAgent;
2323
import com.flowci.core.agent.service.AgentService;
2424
import com.flowci.core.auth.annotation.Action;
25-
import lombok.extern.log4j.Log4j2;
25+
import lombok.extern.slf4j.Slf4j;
2626
import org.springframework.beans.factory.annotation.Autowired;
2727
import org.springframework.validation.annotation.Validated;
2828
import org.springframework.web.bind.annotation.*;
@@ -32,7 +32,7 @@
3232
/**
3333
* @author yang
3434
*/
35-
@Log4j2
35+
@Slf4j
3636
@RestController
3737
@RequestMapping("/agents")
3838
public class AgentController {

core/src/main/java/com/flowci/core/agent/controller/AgentHostController.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
import com.flowci.core.agent.domain.AgentHostOption;
2222
import com.flowci.core.agent.service.AgentHostService;
2323
import com.flowci.core.auth.annotation.Action;
24-
import lombok.extern.log4j.Log4j2;
24+
import lombok.extern.slf4j.Slf4j;
2525
import org.springframework.beans.factory.annotation.Autowired;
2626
import org.springframework.validation.annotation.Validated;
2727
import org.springframework.web.bind.annotation.*;
2828

2929
import java.util.List;
3030

31-
@Log4j2
31+
@Slf4j
3232
@RestController
3333
@RequestMapping("/hosts")
3434
public class AgentHostController {

core/src/main/java/com/flowci/core/agent/manager/AgentEventManager.java

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package com.flowci.core.agent.manager;
22

3+
import com.fasterxml.jackson.core.JacksonException;
34
import com.fasterxml.jackson.databind.ObjectMapper;
45
import com.flowci.core.agent.domain.*;
56
import com.flowci.core.agent.event.*;
67
import com.flowci.core.common.domain.StatusCode;
78
import com.flowci.core.common.domain.http.ResponseMessage;
89
import com.flowci.core.common.manager.SpringEventManager;
9-
import lombok.extern.log4j.Log4j2;
10+
import lombok.extern.slf4j.Slf4j;
1011
import org.springframework.beans.factory.annotation.Autowired;
1112
import org.springframework.stereotype.Component;
1213
import org.springframework.web.socket.BinaryMessage;
@@ -23,7 +24,7 @@
2324
/**
2425
* Handle event from agent via websocket
2526
*/
26-
@Log4j2
27+
@Slf4j
2728
@Component
2829
public class AgentEventManager extends BinaryWebSocketHandler {
2930

@@ -128,8 +129,8 @@ private <T> void writeMessage(WebSocketSession session, ResponseMessage<T> msg)
128129
try {
129130
byte[] bytes = objectMapper.writeValueAsBytes(msg);
130131
writeMessage(session, bytes);
131-
} catch (IOException e) {
132-
log.warn(e);
132+
} catch (JacksonException e) {
133+
log.warn("Unable to convert agent response message", e);
133134
}
134135
}
135136

@@ -138,7 +139,7 @@ private void writeMessage(WebSocketSession session, byte[] body) {
138139
try {
139140
session.sendMessage(new BinaryMessage(body));
140141
} catch (IOException e) {
141-
log.warn(e);
142+
log.warn("Unable to send message", e);
142143
}
143144
}
144145
}
@@ -159,26 +160,22 @@ private void onConnected(WebSocketSession session, String token, byte[] body) {
159160
writeMessage(token, new ResponseMessage<>(StatusCode.OK, agent.getConfig()));
160161
log.debug("Agent {} is connected with status {}", token, init.getStatus());
161162
} catch (Exception e) {
162-
log.warn(e);
163+
log.warn("Agent connected error", e);
163164
writeMessage(session, new ResponseMessage<Void>(StatusCode.FATAL, e.getMessage(), null));
164165
}
165166
}
166167

167168
private void onCmdOut(String token, byte[] body) {
168-
try {
169-
log.debug("Agent {} got cmd back: {}", token, new String(body));
170-
eventManager.publish(new OnCmdOutEvent(this, body));
171-
} catch (Exception e) {
172-
log.warn(e);
173-
}
169+
log.debug("Agent {} got cmd back: {}", token, new String(body));
170+
eventManager.publish(new OnCmdOutEvent(this, body));
174171
}
175172

176173
private void onShellLog(byte[] body) {
177174
try {
178175
ShellLog item = objectMapper.readValue(body, ShellLog.class);
179176
eventManager.publish(new OnShellLogEvent(this, item.getJobId(), item.getStepId(), item.getLog()));
180177
} catch (IOException e) {
181-
log.warn(e);
178+
log.warn("Unable to convert to ShellLog", e);
182179
}
183180
}
184181

@@ -187,7 +184,7 @@ private void onTtyLog(byte[] body) {
187184
TtyCmd.Log item = objectMapper.readValue(body, TtyCmd.Log.class);
188185
eventManager.publish(new OnTTYLogEvent(this, item.getId(), item.getLog()));
189186
} catch (IOException e) {
190-
log.warn(e);
187+
log.warn("Unable to convert to TtyCmd.Log", e);
191188
}
192189
}
193190

@@ -197,7 +194,7 @@ private void onProfile(String token, byte[] body) {
197194
profile.setId(token);
198195
eventManager.publish(new OnAgentProfileEvent(this, profile));
199196
} catch (IOException e) {
200-
log.warn(e);
197+
log.warn("Unable to convert to AgentProfile", e);
201198
}
202199
}
203200

core/src/main/java/com/flowci/core/agent/service/AgentHostServiceImpl.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import com.google.common.base.Preconditions;
4747
import lombok.AllArgsConstructor;
4848
import lombok.extern.log4j.Log4j2;
49+
import lombok.extern.slf4j.Slf4j;
4950
import org.springframework.beans.factory.annotation.Autowired;
5051
import org.springframework.context.event.EventListener;
5152
import org.springframework.core.env.Environment;
@@ -63,7 +64,7 @@
6364
import static com.flowci.core.secret.domain.Secret.Category.KUBE_CONFIG;
6465
import static com.flowci.core.secret.domain.Secret.Category.SSH_RSA;
6566

66-
@Log4j2
67+
@Slf4j
6768
@Service
6869
public class AgentHostServiceImpl implements AgentHostService {
6970

@@ -665,7 +666,7 @@ public int hashCode() {
665666
}
666667
}
667668

668-
@Log4j2
669+
@Slf4j
669670
private static class PoolManagerRemover implements RemovalListener<AgentHost, DockerManager> {
670671

671672
@Override

core/src/main/java/com/flowci/core/agent/service/AgentServiceImpl.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import com.flowci.zookeeper.InterLock;
4141
import com.flowci.zookeeper.ZookeeperClient;
4242
import com.google.common.collect.Sets;
43-
import lombok.extern.log4j.Log4j2;
43+
import lombok.extern.slf4j.Slf4j;
4444
import org.springframework.beans.factory.annotation.Autowired;
4545
import org.springframework.context.event.EventListener;
4646
import org.springframework.dao.DuplicateKeyException;
@@ -60,7 +60,7 @@
6060
*
6161
* @author yang
6262
*/
63-
@Log4j2
63+
@Slf4j
6464
@Service
6565
public class AgentServiceImpl implements AgentService {
6666

@@ -377,7 +377,7 @@ public void dispatch(CmdIn cmd, Agent agent) {
377377
agentEventManager.writeMessage(agent.getToken(), body);
378378
eventManager.publish(new CmdSentEvent(this, agent, cmd));
379379
} catch (IOException e) {
380-
log.warn(e);
380+
log.warn("Unable to write CmdIn", e);
381381
}
382382
}
383383

@@ -450,7 +450,7 @@ private void unlock(InterLock lock) {
450450
zk.release(lock);
451451
log.debug("Unlock: {}", FetchAgentLockKey);
452452
} catch (Exception warn) {
453-
log.warn(warn);
453+
log.warn("Unable to unlock agent", warn);
454454
}
455455
}
456456
}

core/src/main/java/com/flowci/core/api/OpenRestController.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import com.flowci.core.secret.domain.Secret;
3030
import com.flowci.core.user.domain.User;
3131
import com.flowci.exception.ArgumentException;
32-
import lombok.extern.log4j.Log4j2;
32+
import lombok.extern.slf4j.Slf4j;
3333
import org.springframework.beans.factory.annotation.Autowired;
3434
import org.springframework.core.io.InputStreamResource;
3535
import org.springframework.core.io.Resource;
@@ -48,7 +48,7 @@
4848
/**
4949
* Provides API which calling from agent plugin
5050
*/
51-
@Log4j2
51+
@Slf4j
5252
@RestController
5353
@RequestMapping("/api")
5454
public class OpenRestController {

core/src/main/java/com/flowci/core/auth/service/AuthServiceImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
import com.flowci.exception.AuthenticationException;
3131
import com.flowci.exception.NotFoundException;
3232
import com.flowci.util.HashingHelper;
33-
import lombok.extern.log4j.Log4j2;
33+
import lombok.extern.slf4j.Slf4j;
3434
import org.springframework.beans.factory.annotation.Autowired;
3535
import org.springframework.stereotype.Service;
3636

3737
import java.util.Objects;
3838
import java.util.Optional;
3939
import java.util.Set;
4040

41-
@Log4j2
41+
@Slf4j
4242
@Service
4343
public class AuthServiceImpl implements AuthService {
4444

core/src/main/java/com/flowci/core/common/adviser/ExceptionAdviser.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.flowci.core.common.domain.http.ResponseMessage;
2121
import com.flowci.exception.CIException;
2222
import com.flowci.exception.ErrorCode;
23-
import lombok.extern.log4j.Log4j2;
23+
import lombok.extern.slf4j.Slf4j;
2424
import org.springframework.http.HttpStatus;
2525
import org.springframework.web.bind.MethodArgumentNotValidException;
2626
import org.springframework.web.bind.MissingServletRequestParameterException;
@@ -32,7 +32,7 @@
3232
/**
3333
* @author yang
3434
*/
35-
@Log4j2
35+
@Slf4j
3636
@ControllerAdvice({
3737
"com.flowci.core.auth",
3838
"com.flowci.core.user",
@@ -82,7 +82,7 @@ public ResponseMessage<Object> ciException(CIException e) {
8282
@ResponseStatus(HttpStatus.OK)
8383
@ExceptionHandler(Throwable.class)
8484
public ResponseMessage<Object> fatalException(Throwable e) {
85-
log.error(e);
85+
log.error("Fatal exception", e);
8686
return new ResponseMessage<>(StatusCode.FATAL, e.getMessage(), null);
8787
}
8888
}

core/src/main/java/com/flowci/core/common/config/AppConfig.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.flowci.core.common.helper.JacksonHelper;
2222
import com.flowci.core.common.helper.ThreadHelper;
2323
import com.flowci.util.FileHelper;
24-
import lombok.extern.log4j.Log4j2;
24+
import lombok.extern.slf4j.Slf4j;
2525
import org.springframework.boot.autoconfigure.web.servlet.MultipartProperties;
2626
import org.springframework.cache.annotation.EnableCaching;
2727
import org.springframework.context.ApplicationEvent;
@@ -46,7 +46,7 @@
4646
/**
4747
* @author yang
4848
*/
49-
@Log4j2
49+
@Slf4j
5050
@Configuration
5151
@EnableScheduling
5252
@EnableCaching

core/src/main/java/com/flowci/core/common/config/MongoConfig.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,16 @@
2626
import com.flowci.core.config.domain.TextConfig;
2727
import com.flowci.core.flow.domain.Flow;
2828
import com.flowci.core.flow.domain.FlowGroup;
29-
import com.flowci.core.git.domain.GitConfig;
3029
import com.flowci.core.git.domain.GitConfigWithHost;
3130
import com.flowci.core.job.domain.JobItem;
3231
import com.flowci.core.secret.domain.*;
3332
import com.flowci.core.trigger.domain.EmailTrigger;
3433
import com.flowci.core.trigger.domain.WebhookTrigger;
3534
import com.mongodb.ConnectionString;
36-
import com.mongodb.MongoClientSettings;
37-
import com.mongodb.MongoCredential;
3835
import com.mongodb.client.MongoClient;
3936
import com.mongodb.client.MongoClients;
4037
import lombok.NonNull;
41-
import lombok.extern.log4j.Log4j2;
42-
import org.springframework.beans.factory.annotation.Autowired;
38+
import lombok.extern.slf4j.Slf4j;
4339
import org.springframework.boot.autoconfigure.mongo.MongoProperties;
4440
import org.springframework.context.annotation.Bean;
4541
import org.springframework.context.annotation.Configuration;
@@ -58,7 +54,7 @@
5854
/**
5955
* @author yang
6056
*/
61-
@Log4j2
57+
@Slf4j
6258
@Configuration
6359
@EnableMongoAuditing(auditorAwareRef = "sessionManager")
6460
public class MongoConfig extends AbstractMongoClientConfiguration {

core/src/main/java/com/flowci/core/common/config/QueueConfig.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import com.rabbitmq.client.BuiltinExchangeType;
2323
import com.rabbitmq.client.Connection;
2424
import com.rabbitmq.client.ConnectionFactory;
25-
import lombok.extern.log4j.Log4j2;
25+
import lombok.extern.slf4j.Slf4j;
2626
import org.springframework.beans.factory.annotation.Autowired;
2727
import org.springframework.context.annotation.Bean;
2828
import org.springframework.context.annotation.Configuration;
@@ -35,7 +35,7 @@
3535
/**
3636
* @author yang
3737
*/
38-
@Log4j2
38+
@Slf4j
3939
@Configuration
4040
public class QueueConfig {
4141

0 commit comments

Comments
 (0)