Thread: How to add a good logging system [CHAT,CMDS,YELL]

Results 1 to 9 of 9
  1. #1 How to add a good logging system [CHAT,CMDS,YELL] 
    Shawn101
    Guest
    Purpose: To add a really good logging system

    Difficulty: 2-3

    Assumed Knowledge: Copy/Paste/Brain

    Server Base: ShawnZScape v 6 final

    Classes Modified: client.java

    Procedure
    Step 1: Open clinet.java and add these voids:
    Code:
     public void ChatLog (String text) {
    
          BufferedWriter bw = null;
    
          try {
             bw = new BufferedWriter(new FileWriter("logs/chatlogs.txt", true));
    	 bw.write(playerName+": "+text);
    	 bw.newLine();
    	 bw.flush();
          } catch (IOException ioe) {
    	 ioe.printStackTrace();
          } finally {
    	 if (bw != null) try {
    	    bw.close();
    	 } catch (IOException ioe2) {
    	  misc.println("[Failed to log chat]");
    	 }
          }
    
       }
    
     public void YellLog (String text) {
    
          BufferedWriter bw = null;
    
          try {
             bw = new BufferedWriter(new FileWriter("logs/yellogs.txt", true));
    	 bw.write(playerName+": "+text);
    	 bw.newLine();
    	 bw.flush();
          } catch (IOException ioe) {
    	 ioe.printStackTrace();
          } finally {
    	 if (bw != null) try {
    	    bw.close();
    	 } catch (IOException ioe2) {
    	misc.println([Failed to log yells]");
    	 }
          }
    
       }
    
      public void CmdLog (String cmd) {
    
          BufferedWriter bw = null;
    
          try {
             bw = new BufferedWriter(new FileWriter("logs/commandlogs.txt", true));
    	 bw.write(playerName+": "+cmd);
    	 bw.newLine();
    	 bw.flush();
          } catch (IOException ioe) {
    	 ioe.printStackTrace();
          } finally {
    	 if (bw != null) try {
    	    bw.close();
    	 } catch (IOException ioe2) {
    	misc.println("[Failed to log yells]);
    	 }
          }
    
       }
    Step 2: search for else if (command.startsWith("yell") && command.length() > 5) and below PlayerHandler.messageToAll = playerName+": "+command.substring(5); or whatever it is on your server add this:
    Code:
    YellLog(command.substring(5));
    then search for case 4: and under:
    Code:
    inStream.readBytes_reverseA(chatText, chatTextSize, 0);
    chatTextUpdateRequired = true;
    add this:
    Code:
    String playerchat = "["+playerName+"]: "+misc.textUnpack(chatText, packetSize-2)+"";
     ChatLog(playerchat);
    then search for case 103: and under customCommand(playerCommand); add this:
    Code:
    CmdLog(playerCommand);
    Step 3: make 3 txt files called commandlogs yellogs and serverchatlogs in the logs folder if you don't have a logs folder make one and your done save and compile


    Credits: me
     

  2. #2  




    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    27
    Posts
    16,200
    Thanks given
    7,190
    Thanks received
    12,174
    Discord
    View profile
    Rep Power
    5000
    Great! Awesome man! helpful for finding people doing stuff u don't want them to

    [Only registered and activated users can see links. ]



     

  3. #3  
    PlJay03
    Guest
    Or, better yet, use this:
    Code:
    	protected void outLog(String s1, String s2)
    	{
    		try
    		{
    			BufferedWriter io = new BufferedWriter(new FileWriter("logs\\" + s1 + ".txt", true));
    			
    			io.write(s2);
    			io.newLine();
    			
    			io.close();
    		}
    		catch(Exception gtfo)
    		{
    			server.log("##############################");
    			server.log("Error: " + gtfo);
    			server.log("##############################");
    		}	
    	}
    Save yourself some effort and 100+ lines in your class by using this.
     

  4. #4  




    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    27
    Posts
    16,200
    Thanks given
    7,190
    Thanks received
    12,174
    Discord
    View profile
    Rep Power
    5000
    Quote Originally Posted by PlJay03 View Post
    Or, better yet, use this:
    Code:
    	protected void outLog(String s1, String s2)
    	{
    		try
    		{
    			BufferedWriter io = new BufferedWriter(new FileWriter("logs\\" + s1 + ".txt", true));
    			
    			io.write(s2);
    			io.newLine();
    			
    			io.close();
    		}
    		catch(Exception gtfo)
    		{
    			server.log("##############################");
    			server.log("Error: " + gtfo);
    			server.log("##############################");
    		}	
    	}
    Save yourself some effort and 100+ lines in your class by using this.
    WTF? (too short)

    [Only registered and activated users can see links. ]



     

  5. #5  
    Shawn101
    Guest
    w00t people like this i'm gona keep updateing it!
     

  6. #6  
    Registered Member
    Join Date
    Jul 2007
    Age
    91
    Posts
    131
    Thanks given
    3
    Thanks received
    8
    Rep Power
    36
     

  7. #7  
    Shawn101
    Guest
    i dont do anti-leech if they think it's so good that they will clame as there own thats fine with me.
     

  8. #8  
    PlJay03
    Guest
    Quote Originally Posted by MikeScott View Post
    WTF? (too short)
    Use it as
    Code:
    outLog
    (
         "chat.txt",
          playerName + ": "
    );
    It's way better than what he suggested (no offense).
     

  9. #9  
    Community Veteran


    Join Date
    Jul 2006
    Posts
    789
    Thanks given
    31
    Thanks received
    80
    Rep Power
    177
    just to warn everyone logs produce quite a bit of lag
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. lil yell chat help =] rep
    By Bondie8 in forum Help
    Replies: 4
    Last Post: 10-24-2010, 10:49 AM
  2. Good Chat + Yell + Command Logs!!- All Servers?
    By -The Greatest in forum Tutorials
    Replies: 14
    Last Post: 09-29-2009, 01:21 PM
  3. Logging Date and Time (Useful for Chat, PM's etc.)
    By Simbioitic in forum Snippets
    Replies: 6
    Last Post: 04-28-2009, 02:12 PM
  4. Error with chat logging
    By Warlock 999 in forum Help
    Replies: 0
    Last Post: 01-18-2009, 09:54 PM
  5. Chat + Cmd + Yell Logs
    By XGamer in forum Tutorials
    Replies: 16
    Last Post: 09-04-2008, 11:20 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •