1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-08-13 16:53:50 -04:00

Removed logging from PircBot

This commit is contained in:
Sebastian Kaspari 2010-03-21 15:42:53 +01:00
parent 5e3ddc30c2
commit 81c24c5128
4 changed files with 1 additions and 108 deletions

View File

@ -56,8 +56,7 @@ public class IdentServer extends Thread {
* @param bot The PircBot instance that will be used to log to.
* @param login The login that the ident server will respond with.
*/
IdentServer(PircBot bot, String login) {
_bot = bot;
IdentServer(String login) {
_login = login;
try {
@ -65,11 +64,9 @@ public class IdentServer extends Thread {
_ss.setSoTimeout(60000);
}
catch (Exception e) {
_bot.log("*** Could not start the ident server on port 113.");
return;
}
_bot.log("*** Ident server running on port 113 for the next 60 seconds...");
this.setName(this.getClass() + "-Thread");
this.start();
}
@ -90,11 +87,9 @@ public class IdentServer extends Thread {
String line = reader.readLine();
if (line != null) {
_bot.log("*** Ident request received: " + line);
line = line + " : USERID : UNIX : " + _login;
writer.write(line + "\r\n");
writer.flush();
_bot.log("*** Ident reply sent: " + line);
writer.close();
}
}
@ -109,10 +104,8 @@ public class IdentServer extends Thread {
// Doesn't really matter...
}
_bot.log("*** The Ident server has been shut down.");
}
private PircBot _bot;
private String _login;
private ServerSocket _ss = null;

View File

@ -16,7 +16,6 @@ package org.jibble.pircbot;
import java.io.*;
import java.net.*;
import java.util.*;
/**
* A Thread which reads lines from the IRC server. It then
@ -97,17 +96,6 @@ public class InputThread extends Thread {
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
pw.flush();
StringTokenizer tokenizer = new StringTokenizer(sw.toString(), "\r\n");
synchronized (_bot) {
_bot.log("### Your implementation of PircBot is faulty and you have");
_bot.log("### allowed an uncaught Exception or Error to propagate in your");
_bot.log("### code. It may be possible for PircBot to continue operating");
_bot.log("### normally. Here is the stack trace that was produced: -");
_bot.log("### ");
while (tokenizer.hasMoreTokens()) {
_bot.log("### " + tokenizer.nextToken());
}
}
}
}
if (line == null) {
@ -136,7 +124,6 @@ public class InputThread extends Thread {
}
if (!_disposed) {
_bot.log("*** Disconnected.");
_isConnected = false;
_bot.onDisconnect();
}

View File

@ -64,7 +64,6 @@ public class OutputThread extends Thread {
try {
bwriter.write(line + "\r\n");
bwriter.flush();
bot.log(">>>" + line);
}
catch (Exception e) {
// Silent response - just lose the line.

View File

@ -29,8 +29,6 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.StringTokenizer;
import android.util.Log;
/**
* PircBot is a Java framework for writing IRC bots quickly and easily.
* <p>
@ -147,7 +145,6 @@ public abstract class PircBot implements ReplyConstants {
// Connect to the server.
Socket socket = new Socket(hostname, port);
this.log("*** Connected to server.");
_inetAddress = socket.getLocalAddress();
@ -215,8 +212,6 @@ public abstract class PircBot implements ReplyConstants {
}
this.log("*** Logged onto server.");
// This makes the socket timeout on read operations after 5 minutes.
// Maybe in some future version I will let the user change this at runtime.
socket.setSoTimeout(5 * 60 * 1000);
@ -282,41 +277,6 @@ public abstract class PircBot implements ReplyConstants {
_autoNickChange = autoNickChange;
}
/**
* Starts an ident server (Identification Protocol Server, RFC 1413).
* <p>
* Most IRC servers attempt to contact the ident server on connecting
* hosts in order to determine the user's identity. A few IRC servers
* will not allow you to connect unless this information is provided.
* <p>
* So when a PircBot is run on a machine that does not run an ident server,
* it may be necessary to call this method to start one up.
* <p>
* Calling this method starts up an ident server which will respond with
* the login provided by calling getLogin() and then shut down immediately.
* It will also be shut down if it has not been contacted within 60 seconds
* of creation.
* <p>
* If you require an ident response, then the correct procedure is to start
* the ident server and then connect to the IRC server. The IRC server may
* then contact the ident server to get the information it needs.
* <p>
* The ident server will fail to start if there is already an ident server
* running on port 113, or if you are running as an unprivileged user who
* is unable to create a server socket on that port number.
* <p>
* If it is essential for you to use an ident server when connecting to an
* IRC server, then make sure that port 113 on your machine is visible to
* the IRC server so that it may contact the ident server.
*
* @since PircBot 0.9c
*/
public final void startIdentServer() {
new IdentServer(this, getLogin());
}
/**
* Joins a channel.
*
@ -843,35 +803,6 @@ public abstract class PircBot implements ReplyConstants {
throw new RuntimeException("dccAcceptChatRequest is deprecated, please use onIncomingChatRequest");
}
/**
* Adds a line to the log. This log is currently output to the standard
* output and is in the correct format for use by tools such as pisg, the
* Perl IRC Statistics Generator. You may override this method if you wish
* to do something else with log entries.
* Each line in the log begins with a number which
* represents the logging time (as the number of milliseconds since the
* epoch). This timestamp and the following log entry are separated by
* a single space character, " ". Outgoing messages are distinguishable
* by a log entry that has ">>>" immediately following the space character
* after the timestamp. DCC events use "+++" and warnings about unhandled
* Exceptions and Errors use "###".
* <p>
* This implementation of the method will only cause log entries to be
* output if the PircBot has had its verbose mode turned on by calling
* setVerbose(true);
*
* @param line The line to add to the log.
*/
public void log(String line) {
if (_verbose) {
// XXX: PircBot Patch: Log to debug log instead of standard output
Log.d(TAG, line);
//System.out.println(System.currentTimeMillis() + " " + line);
}
}
/**
* This method handles events when any line of text arrives from the server,
* then calling the appropriate method in the PircBot. This method is
@ -882,8 +813,6 @@ public abstract class PircBot implements ReplyConstants {
* @param line The raw line of text from the server.
*/
protected void handleLine(String line) {
this.log(line);
// Check for server pings.
if (line.startsWith("PING ")) {
// Respond to the ping and return immediately.
@ -2334,20 +2263,6 @@ public abstract class PircBot implements ReplyConstants {
protected void onUnknown(String line) {
// And then there were none :)
}
/**
* Sets the verbose mode. If verbose mode is set to true, then log entries
* will be printed to the standard output. The default value is false and
* will result in no output. For general development, we strongly recommend
* setting the verbose mode to true.
*
* @param verbose true if verbose mode is to be used. Default is false.
*/
public final void setVerbose(boolean verbose) {
_verbose = verbose;
}
/**
* Sets the name of the bot, which will be used as its nick when it
@ -3096,7 +3011,6 @@ public abstract class PircBot implements ReplyConstants {
// Default settings for the PircBot.
private boolean _autoNickChange = false;
private boolean _verbose = false;
private String _name = "PircBot";
private String _nick = _name;
private String _login = "PircBot";