Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 834fefb

Browse files
authored
Add timestamps to log (#178)
1 parent b754337 commit 834fefb

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ ENV APP_NAME="${APP_NAME}"
2525
ENTRYPOINT [\
2626
"/tini", "--",\
2727
"/bin/sh","-c",\
28-
"java -Dircbot.name=jenkins-admin -jar /usr/local/bin/${APP_NAME}.jar"]
28+
"java -Dircbot.name=jenkins-admin -Dorg.slf4j.simpleLogger.showDateTime=true -Dorg.slf4j.simpleLogger.dateTimeFormat='yyyy-MM-dd HH:mm:ss:SSS Z' -jar /usr/local/bin/${APP_NAME}.jar"]

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,8 @@ Setting up the environment:
5656

5757
Running the bot for testing:
5858

59+
```sh
60+
java -Dircbot.name=test-ircbot -Dircbot.channels="#jenkins-ircbot-test" -Dircbot.testSuperUser="${YOUR_IRC_NAME}" -Dircbot.github.organization="jenkinsci-infra-ircbot-test" -Dircbot.jira.url=${JIRA_URL} -Dircbot.jira.defaultProject=TEST -jar target/ircbot-2.0-SNAPSHOT-bin/ircbot-2.0-SNAPSHOT.jar
5961
```
60-
java -Dircbot.name=test-ircbot \
61-
-Dircbot.channels="#jenkins-ircbot-test" \
62-
-Dircbot.testSuperUser="${YOUR_IRC_NAME}" \
63-
-Dircbot.github.organization="jenkinsci-infra-ircbot-test" \
64-
-Dircbot.jira.url=${JIRA_URL} \
65-
-Dircbot.jira.defaultProject=TEST \
66-
-jar target/ircbot-2.0-SNAPSHOT-bin/ircbot-2.0-SNAPSHOT.jar
67-
```
68-
62+
6963
After executing this command the bot should connect to your IRC chat.

src/main/java/org/jenkinsci/backend/ircbot/IrcListener.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import org.pircbotx.UserLevel;
3737
import org.pircbotx.output.OutputChannel;
3838
import org.pircbotx.output.OutputIRC;
39+
import org.slf4j.Logger;
40+
import org.slf4j.LoggerFactory;
3941

4042
import javax.net.ssl.HttpsURLConnection;
4143
import javax.net.ssl.SSLContext;
@@ -67,6 +69,9 @@
6769
* @author Kohsuke Kawaguchi
6870
*/
6971
public class IrcListener extends ListenerAdapter {
72+
73+
private static final Logger LOGGER = LoggerFactory.getLogger(IrcListener.class);
74+
7075
/**
7176
* Records commands that we didn't understand.
7277
*/
@@ -108,7 +113,8 @@ public void onMessage(MessageEvent e) {
108113
}
109114
} catch (RuntimeException ex) { // Catch unhandled runtime issues
110115
ex.printStackTrace();
111-
channel.send().message("An error ocurred in the Bot. Please submit a bug to Jenkins INFRA project.");
116+
channel.send().message("An error ocurred. Please submit a ticket to the Jenkins infra helpdesk with the following exception:");
117+
channel.send().message("https://github.com/jenkins-infra/helpdesk/issues/new?assignees=&labels=triage,irc&template=1-report-issue.yml");
112118
channel.send().message(ex.getMessage());
113119
throw ex; // Propagate the error to the caller in order to let it log and handle the issue
114120
}
@@ -878,7 +884,7 @@ boolean forkGitHub(Channel channel, User sender, String owner, String repo, Stri
878884
} catch (IOException e) {
879885
// we started seeing 500 errors, presumably due to time out.
880886
// give it a bit of time, and see if the repository is there
881-
System.out.println("GitHub reported that it failed to fork "+owner+"/"+repo+". But we aren't trusting");
887+
LOGGER.warn("GitHub reported that it failed to fork {}/{}. But we aren't trusting", owner, repo);
882888
r = null;
883889
for (int i=0; r==null && i<5; i++) {
884890
Thread.sleep(1000);
@@ -1011,8 +1017,8 @@ public static void main(String[] args) throws Exception {
10111017
.addCapHandler(new SASLCapHandler(IrcBotConfig.NAME, args[0]));
10121018
}
10131019

1014-
System.out.println("Connecting to "+IrcBotConfig.SERVER+" as "+IrcBotConfig.NAME);
1015-
System.out.println("GitHub organization = "+IrcBotConfig.GITHUB_ORGANIZATION);
1020+
LOGGER.info("Connecting to {} as {}.", IrcBotConfig.SERVER, IrcBotConfig.NAME);
1021+
LOGGER.info("GitHub organization: {}", IrcBotConfig.GITHUB_ORGANIZATION);
10161022

10171023
PircBotX bot = new PircBotX(builder.buildConfiguration());
10181024
bot.startBot();

0 commit comments

Comments
 (0)