summaryrefslogtreecommitdiffstats
path: root/src/org/jogamp/jabot/irc/LogBot.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-01-19 08:49:32 +0100
committerSven Gothel <[email protected]>2013-01-19 08:49:32 +0100
commit60ccfc5ff7dee58740ba1302626e3ccea35259b9 (patch)
tree326619264a1b24d8c21332b4deae98127dc24ec4 /src/org/jogamp/jabot/irc/LogBot.java
parent6b370c09e17285d703e805a6fbfbc341d5ec1b60 (diff)
Add id/href to each line enabling linking to each message; Simplify loop; Set logstream before start; Add logrotateStart time.
Diffstat (limited to 'src/org/jogamp/jabot/irc/LogBot.java')
-rw-r--r--src/org/jogamp/jabot/irc/LogBot.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/org/jogamp/jabot/irc/LogBot.java b/src/org/jogamp/jabot/irc/LogBot.java
index e334ae8..9c085a2 100644
--- a/src/org/jogamp/jabot/irc/LogBot.java
+++ b/src/org/jogamp/jabot/irc/LogBot.java
@@ -43,6 +43,7 @@ public class LogBot extends PircBot {
private final boolean xmlOut;
private final Object outSync = new Object();
private PrintStream out;
+ private int lineCount;
public LogBot(boolean showHostname, String joinMessage, boolean xmlOut) {
this(showHostname, joinMessage, TimeTool.getNearZuluTimeZone(), Locale.getDefault(), System.out, xmlOut);
@@ -54,6 +55,7 @@ public class LogBot extends PircBot {
this.xmlOut = xmlOut;
this.out = out;
this.joinMessage = joinMessage;
+ this.lineCount = 0;
}
public final void setLoginAndName(String login, String nick) {
@@ -93,16 +95,28 @@ public class LogBot extends PircBot {
return out;
}
}
- public PrintStream setOut(PrintStream newOut) {
+ public PrintStream setOut(PrintStream newOut, boolean resetLineCount) {
synchronized(outSync) {
final PrintStream old = out;
out = newOut;
+ if( resetLineCount ) {
+ lineCount = 0;
+ }
return old;
}
}
+ public int getLineCount() {
+ return lineCount;
+ }
+ public void resetLineCount() {
+ synchronized(outSync) {
+ lineCount = 0;
+ }
+ }
public void append(String color, String line) {
tick();
+ lineCount++;
if(xmlOut) {
line = Colors.removeFormattingAndColors(line);
@@ -117,7 +131,8 @@ public class LogBot extends PircBot {
synchronized(outSync) {
if(xmlOut) {
- out.println("<span class=\"irc-date\">[" + getTimeStamp() + "]</span> <span class=\"" + color + "\">" + line + "</span><br />");
+ // <span class="irc-date" id="l232"><a href="#l232">20130117 21:06:04</a></span>
+ out.println("<span class=\"irc-date\" id=\"l"+lineCount+"\"><a href=\"#l"+lineCount+"\">" + getTimeStamp() + "</a></span> <span class=\"" + color + "\">" + line + "</span><br />");
} else {
out.println(getTimeStamp()+" "+line);
}