refactored
This commit is contained in:
parent
1585766b5a
commit
302d193651
@ -4,19 +4,19 @@
|
|||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package netz;
|
package chatProg;
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.WindowConstants;
|
import javax.swing.WindowConstants;
|
||||||
import netz.controller.ReceiveAdapter;
|
import chatProg.controller.ReceiveAdapter;
|
||||||
import netz.controller.CommandConnect;
|
import chatProg.controller.CommandConnect;
|
||||||
import netz.controller.CommandSend;
|
import chatProg.controller.CommandSend;
|
||||||
import netz.model.ChatModel;
|
import chatProg.model.ChatModel;
|
||||||
import netz.view.ChatView;
|
import chatProg.view.ChatView;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import ohmlogger.OhmLogger;
|
import chatProg.logger.OhmLogger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
@ -4,15 +4,15 @@
|
|||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package netz.controller;
|
package chatProg.controller;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import ohmlogger.OhmLogger;
|
import chatProg.logger.OhmLogger;
|
||||||
import netz.model.ChatModel;
|
import chatProg.model.ChatModel;
|
||||||
import netz.view.ChatView;
|
import chatProg.view.ChatView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
@ -4,14 +4,14 @@
|
|||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package netz.controller;
|
package chatProg.controller;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import ohmlogger.OhmLogger;
|
import chatProg.logger.OhmLogger;
|
||||||
import netz.model.ChatModel;
|
import chatProg.model.ChatModel;
|
||||||
import netz.view.ChatView;
|
import chatProg.view.ChatView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
@ -4,13 +4,13 @@
|
|||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package netz.controller;
|
package chatProg.controller;
|
||||||
|
|
||||||
import java.util.concurrent.Flow;
|
import java.util.concurrent.Flow;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import ohmlogger.OhmLogger;
|
import chatProg.logger.OhmLogger;
|
||||||
import netz.model.ChatModel;
|
import chatProg.model.ChatModel;
|
||||||
import netz.view.ChatView;
|
import chatProg.view.ChatView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
26
src/chatProg/logger/MyFormatter.java
Normal file
26
src/chatProg/logger/MyFormatter.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package chatProg.logger;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.logging.Formatter;
|
||||||
|
import java.util.logging.LogRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author chris
|
||||||
|
*/
|
||||||
|
public class MyFormatter extends Formatter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String format(LogRecord lr) {
|
||||||
|
String date = String.format("%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp", new Date(lr.getMillis()));
|
||||||
|
String s = ("| ")+lr.getMillis()+(" | ")+date+(" | ")+lr.getLevel().toString()+(" | ")+lr.getSourceClassName()+(" | ")+lr.getMessage()+(" | ")+"\n";
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
54
src/chatProg/logger/OhmLogger.java
Normal file
54
src/chatProg/logger/OhmLogger.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package chatProg.logger;
|
||||||
|
|
||||||
|
|
||||||
|
import chatProg.logger.MyFormatter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author chris, hd
|
||||||
|
*/
|
||||||
|
public class OhmLogger
|
||||||
|
{
|
||||||
|
public OhmLogger()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
private static Logger lg = null;
|
||||||
|
public static Logger getLogger()
|
||||||
|
{
|
||||||
|
if (lg == null)
|
||||||
|
{
|
||||||
|
lg = Logger.getLogger("OhmLogger");
|
||||||
|
initLogger();
|
||||||
|
}
|
||||||
|
return lg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void initLogger()
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
String datei = System.getProperty("java.io.tmpdir") + File.separator + "log.txt";
|
||||||
|
FileHandler fh = new FileHandler(datei);
|
||||||
|
ConsoleHandler ch = new ConsoleHandler();
|
||||||
|
lg.addHandler(fh);
|
||||||
|
ch.setFormatter(new MyFormatter());
|
||||||
|
lg.setUseParentHandlers(false);
|
||||||
|
lg.addHandler(ch);
|
||||||
|
lg.setLevel(Level.ALL);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(IOException ioex)
|
||||||
|
{
|
||||||
|
System.err.println(ioex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,10 +4,10 @@
|
|||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package netz.model;
|
package chatProg.model;
|
||||||
|
|
||||||
|
|
||||||
import ohmlogger.OhmLogger;
|
import chatProg.logger.OhmLogger;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
@ -3,7 +3,7 @@
|
|||||||
* To change this template file, choose Tools | Templates
|
* To change this template file, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
package netz.view;
|
package chatProg.view;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
Loading…
x
Reference in New Issue
Block a user