Source code: org/alicebot/server/core/logging/XMLLog.java
1 // Decompiled by Jad v1.5.8c. Copyright 2001 Pavel Kouznetsov.
2 // Jad home page: http://www.geocities.com/kpdus/jad.html
3 // Decompiler options: packimports(3)
4
5 package org.alicebot.server.core.logging;
6
7 import java.util.HashMap;
8 import org.alicebot.server.core.Globals;
9 import org.alicebot.server.core.util.XMLResourceSpec;
10 import org.alicebot.server.core.util.XMLWriter;
11
12 public class XMLLog
13 {
14
15 public XMLLog()
16 {
17 }
18
19 public static XMLResourceSpec getChatlogSpecClone()
20 {
21 return (XMLResourceSpec)GENERIC_CHAT.clone();
22 }
23
24 public static void log(String s, XMLResourceSpec xmlresourcespec)
25 {
26 Object obj = entryCounts.get(xmlresourcespec);
27 if(obj != null)
28 {
29 int i = ((Integer)obj).intValue();
30 if(xmlresourcespec.rolloverAtMax)
31 {
32 if(++i % ROLLOVER == 0)
33 XMLWriter.rollover(xmlresourcespec);
34 entryCounts.put(xmlresourcespec, new Integer(i));
35 }
36 } else
37 if(xmlresourcespec.rolloverAtRestart)
38 {
39 XMLWriter.rollover(xmlresourcespec);
40 entryCounts.put(xmlresourcespec, new Integer(1));
41 }
42 XMLWriter.write(s, xmlresourcespec);
43 }
44
45 private static final String ENC_UTF8 = "UTF-8";
46 private static HashMap entryCounts = new HashMap();
47 private static final String RESOURCE_BASE = Globals.getProperty("programd.logging.xml.resource-base", "../resources/");
48 private static final XMLResourceSpec GENERIC_CHAT;
49 private static int ROLLOVER;
50
51 static
52 {
53 GENERIC_CHAT = new XMLResourceSpec();
54 GENERIC_CHAT.description = "Chat Log";
55 GENERIC_CHAT.rolloverAtMax = true;
56 GENERIC_CHAT.rolloverAtRestart = Boolean.valueOf(Globals.getProperty("programd.logging.xml.chat.rollover-at-restart", "true")).booleanValue();
57 GENERIC_CHAT.root = "exchanges";
58 GENERIC_CHAT.stylesheet = Globals.getProperty("programd.logging.xml.chat.stylesheet-path", RESOURCE_BASE + "logs/view-chat.xsl");
59 GENERIC_CHAT.encoding = Globals.getProperty("programd.logging.xml.chat.encoding", "UTF-8");
60 GENERIC_CHAT.dtd = XMLResourceSpec.HTML_ENTITIES_DTD;
61 try
62 {
63 ROLLOVER = Integer.parseInt(Globals.getProperty("programd.logging.xml.rollover", "2000"));
64 }
65 catch(NumberFormatException numberformatexception)
66 {
67 ROLLOVER = 2000;
68 }
69 }
70 }