Skip to content

Commit

Permalink
Add timestamps to log (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotMyFault committed Jan 25, 2023
1 parent b754337 commit 834fefb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -25,4 +25,4 @@ ENV APP_NAME="${APP_NAME}"
ENTRYPOINT [\
"/tini", "--",\
"/bin/sh","-c",\
"java -Dircbot.name=jenkins-admin -jar /usr/local/bin/${APP_NAME}.jar"]
"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"]
12 changes: 3 additions & 9 deletions README.md
Expand Up @@ -56,14 +56,8 @@ Setting up the environment:

Running the bot for testing:

```sh
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
```
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
```


After executing this command the bot should connect to your IRC chat.
14 changes: 10 additions & 4 deletions src/main/java/org/jenkinsci/backend/ircbot/IrcListener.java
Expand Up @@ -36,6 +36,8 @@
import org.pircbotx.UserLevel;
import org.pircbotx.output.OutputChannel;
import org.pircbotx.output.OutputIRC;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -67,6 +69,9 @@
* @author Kohsuke Kawaguchi
*/
public class IrcListener extends ListenerAdapter {

private static final Logger LOGGER = LoggerFactory.getLogger(IrcListener.class);

/**
* Records commands that we didn't understand.
*/
Expand Down Expand Up @@ -108,7 +113,8 @@ public void onMessage(MessageEvent e) {
}
} catch (RuntimeException ex) { // Catch unhandled runtime issues
ex.printStackTrace();
channel.send().message("An error ocurred in the Bot. Please submit a bug to Jenkins INFRA project.");
channel.send().message("An error ocurred. Please submit a ticket to the Jenkins infra helpdesk with the following exception:");
channel.send().message("https://github.com/jenkins-infra/helpdesk/issues/new?assignees=&labels=triage,irc&template=1-report-issue.yml");
channel.send().message(ex.getMessage());
throw ex; // Propagate the error to the caller in order to let it log and handle the issue
}
Expand Down Expand Up @@ -878,7 +884,7 @@ boolean forkGitHub(Channel channel, User sender, String owner, String repo, Stri
} catch (IOException e) {
// we started seeing 500 errors, presumably due to time out.
// give it a bit of time, and see if the repository is there
System.out.println("GitHub reported that it failed to fork "+owner+"/"+repo+". But we aren't trusting");
LOGGER.warn("GitHub reported that it failed to fork {}/{}. But we aren't trusting", owner, repo);
r = null;
for (int i=0; r==null && i<5; i++) {
Thread.sleep(1000);
Expand Down Expand Up @@ -1011,8 +1017,8 @@ public static void main(String[] args) throws Exception {
.addCapHandler(new SASLCapHandler(IrcBotConfig.NAME, args[0]));
}

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

PircBotX bot = new PircBotX(builder.buildConfiguration());
bot.startBot();
Expand Down

0 comments on commit 834fefb

Please sign in to comment.