Compare commits
5 Commits
d94d366315
...
af863d9514
Author | SHA1 | Date | |
---|---|---|---|
![]() |
af863d9514 | ||
![]() |
368575442f | ||
![]() |
bb5837f51c | ||
![]() |
10128a50b0 | ||
![]() |
ea7e96b32c |
@ -15,6 +15,7 @@ import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.Socket;
|
||||
import java.util.logging.Logger;
|
||||
import ohmlogger.OhmLogger;
|
||||
|
||||
/**
|
||||
* Builder Class
|
||||
@ -22,7 +23,7 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class Client
|
||||
{
|
||||
private static final Logger lg = Logger.getLogger("netz");
|
||||
private static Logger lg = OhmLogger.getLogger();
|
||||
private static final int PORT = 35000;
|
||||
private static final String IP_ADRESSE = "127.0.0.1";
|
||||
|
||||
|
@ -16,6 +16,7 @@ import java.io.PrintWriter;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.util.logging.Logger;
|
||||
import ohmlogger.OhmLogger;
|
||||
|
||||
/**
|
||||
* Builder Class
|
||||
@ -23,7 +24,7 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class Server
|
||||
{
|
||||
private static final Logger lg = Logger.getLogger("netz");
|
||||
private static Logger lg = OhmLogger.getLogger();
|
||||
private static final int PORT = 35000;
|
||||
|
||||
public Server() throws IOException
|
||||
|
@ -6,65 +6,80 @@
|
||||
|
||||
package netz;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.WindowConstants;
|
||||
import netz.controller.BtnController;
|
||||
import netz.controller.ChatController;
|
||||
import netz.model.ChatModel;
|
||||
import netz.view.ChatView;
|
||||
|
||||
/**
|
||||
* Builder Class
|
||||
* @author le
|
||||
* @author chris, hd
|
||||
*/
|
||||
public class Start
|
||||
{
|
||||
public Start(String urlString, String dateiname) throws MalformedURLException, IOException
|
||||
public Start() throws MalformedURLException, IOException
|
||||
{
|
||||
URL oUrl = new URL(urlString + "/" + dateiname);
|
||||
InputStream iStream = oUrl.openStream();
|
||||
BufferedInputStream in = new BufferedInputStream(iStream);
|
||||
// URL oUrl = new URL(urlString + "/" + dateiname);
|
||||
// InputStream iStream = oUrl.openStream();
|
||||
// BufferedInputStream in = new BufferedInputStream(iStream);
|
||||
//
|
||||
// String tmpVerzeichnis = System.getProperty("java.io.tmpdir");
|
||||
// String ausgabeDateiname = tmpVerzeichnis + File.separator + dateiname;
|
||||
//
|
||||
// FileOutputStream fos = new FileOutputStream(ausgabeDateiname);
|
||||
// BufferedOutputStream out = new BufferedOutputStream(fos);
|
||||
//
|
||||
// int wert = 0;
|
||||
//
|
||||
// while ( (wert = in.read()) >= 0)
|
||||
// {
|
||||
// out.write(wert);
|
||||
// }
|
||||
// in.close();
|
||||
// out.close(); // flush!
|
||||
// System.out.println("Datei " + ausgabeDateiname + " erfolgreich erstellt");
|
||||
|
||||
String tmpVerzeichnis = System.getProperty("java.io.tmpdir");
|
||||
String ausgabeDateiname = tmpVerzeichnis + File.separator + dateiname;
|
||||
JFrame frm = new JFrame();
|
||||
frm.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
ChatView view = new ChatView();
|
||||
ChatModel model = new ChatModel();
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(ausgabeDateiname);
|
||||
BufferedOutputStream out = new BufferedOutputStream(fos);
|
||||
|
||||
int wert = 0;
|
||||
|
||||
while ( (wert = in.read()) >= 0)
|
||||
{
|
||||
out.write(wert);
|
||||
}
|
||||
in.close();
|
||||
out.close(); // flush!
|
||||
System.out.println("Datei " + ausgabeDateiname + " erfolgreich erstellt");
|
||||
BtnController btncontroller = new BtnController(view, model);
|
||||
ChatController chatcontroller = new ChatController(view, model);
|
||||
btncontroller.registerEvents();
|
||||
chatcontroller.registerEvents();
|
||||
|
||||
view.setSize(800, 600);
|
||||
view.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
if (args.length != 2)
|
||||
try
|
||||
{
|
||||
System.err.println("2 Aufrufparameter nötig: URL-String Dateiname");
|
||||
new Start();
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
new Start(args[0], args[1]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.err.println(ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
System.err.println(ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
try
|
||||
{
|
||||
new Start();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.err.println(ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
50
src/netz/controller/BtnController.java
Normal file
50
src/netz/controller/BtnController.java
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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 netz.controller;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.logging.Logger;
|
||||
import netz.model.ChatModel;
|
||||
import netz.view.ChatView;
|
||||
import ohmlogger.OhmLogger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chris
|
||||
*/
|
||||
public class BtnController implements ActionListener
|
||||
{
|
||||
private ChatView view;
|
||||
private ChatModel model;
|
||||
private static Logger lg = OhmLogger.getLogger();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param view
|
||||
* @param model
|
||||
*/
|
||||
public BtnController(ChatView view, ChatModel model)
|
||||
{
|
||||
this.view = view;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public void registerEvents()
|
||||
{
|
||||
view.getBtnSetClient().addActionListener(this);
|
||||
view.getBtnSetServer().addActionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
49
src/netz/controller/ChatController.java
Normal file
49
src/netz/controller/ChatController.java
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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 netz.controller;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.logging.Logger;
|
||||
import netz.model.ChatModel;
|
||||
import netz.view.ChatView;
|
||||
import ohmlogger.OhmLogger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chris
|
||||
*/
|
||||
public class ChatController implements ActionListener
|
||||
{
|
||||
private ChatView view;
|
||||
private ChatModel model;
|
||||
private static Logger lg = OhmLogger.getLogger();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param view
|
||||
* @param model
|
||||
*/
|
||||
public ChatController(ChatView view, ChatModel model)
|
||||
{
|
||||
this.view = view;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public void registerEvents()
|
||||
{
|
||||
view.getBtnSend().addActionListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
19
src/netz/model/ChatModel.java
Normal file
19
src/netz/model/ChatModel.java
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* 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 netz.model;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chris
|
||||
*/
|
||||
public class ChatModel
|
||||
{
|
||||
public ChatModel()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
87
src/netz/view/ChatView.form
Normal file
87
src/netz/view/ChatView.form
Normal file
@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
<Property name="title" type="java.lang.String" value="ChatTool"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="First"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
|
||||
<Property name="columns" type="int" value="0"/>
|
||||
<Property name="rows" type="int" value="1"/>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="lblType">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Client"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnSetClient">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Client"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnSetServer">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Server"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JTextField" name="txtField">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jTextField1"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnSend">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Send"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="After"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lblStatusDialog">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value=""""/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Last"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
204
src/netz/view/ChatView.java
Normal file
204
src/netz/view/ChatView.java
Normal file
@ -0,0 +1,204 @@
|
||||
/*
|
||||
* 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 netz.view;
|
||||
|
||||
import netz.view.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hd
|
||||
*/
|
||||
public class ChatView extends javax.swing.JFrame
|
||||
{
|
||||
|
||||
/**
|
||||
* @return the btnSend
|
||||
*/
|
||||
public javax.swing.JButton getBtnSend()
|
||||
{
|
||||
return btnSend;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the btnSetClient
|
||||
*/
|
||||
public javax.swing.JButton getBtnSetClient()
|
||||
{
|
||||
return btnSetClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the btnSetServer
|
||||
*/
|
||||
public javax.swing.JButton getBtnSetServer()
|
||||
{
|
||||
return btnSetServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lblStatusDialog
|
||||
*/
|
||||
public javax.swing.JLabel getLblStatusDialog()
|
||||
{
|
||||
return lblStatusDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lblStatusDialog the lblStatusDialog to set
|
||||
*/
|
||||
public void setLblStatusDialog(javax.swing.JLabel lblStatusDialog)
|
||||
{
|
||||
this.lblStatusDialog = lblStatusDialog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lblType
|
||||
*/
|
||||
public javax.swing.JLabel getLblType()
|
||||
{
|
||||
return lblType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lblType the lblType to set
|
||||
*/
|
||||
public void setLblType(javax.swing.JLabel lblType)
|
||||
{
|
||||
this.lblType = lblType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the txtField
|
||||
*/
|
||||
public javax.swing.JTextField getTxtField()
|
||||
{
|
||||
return txtField;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param txtField the txtField to set
|
||||
*/
|
||||
public void setTxtField(javax.swing.JTextField txtField)
|
||||
{
|
||||
this.txtField = txtField;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new form chatView
|
||||
*/
|
||||
public ChatView()
|
||||
{
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents()
|
||||
{
|
||||
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
lblType = new javax.swing.JLabel();
|
||||
btnSetClient = new javax.swing.JButton();
|
||||
btnSetServer = new javax.swing.JButton();
|
||||
txtField = new javax.swing.JTextField();
|
||||
btnSend = new javax.swing.JButton();
|
||||
lblStatusDialog = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setTitle("ChatTool");
|
||||
|
||||
jPanel1.setLayout(new java.awt.GridLayout(1, 0));
|
||||
|
||||
lblType.setText("Client");
|
||||
jPanel1.add(lblType);
|
||||
|
||||
btnSetClient.setText("Client");
|
||||
jPanel1.add(btnSetClient);
|
||||
|
||||
btnSetServer.setText("Server");
|
||||
jPanel1.add(btnSetServer);
|
||||
|
||||
getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);
|
||||
|
||||
txtField.setText("jTextField1");
|
||||
getContentPane().add(txtField, java.awt.BorderLayout.CENTER);
|
||||
|
||||
btnSend.setText("Send");
|
||||
getContentPane().add(btnSend, java.awt.BorderLayout.LINE_END);
|
||||
|
||||
lblStatusDialog.setText("\"\"");
|
||||
getContentPane().add(lblStatusDialog, java.awt.BorderLayout.PAGE_END);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
*/
|
||||
public static void main(String args[])
|
||||
{
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try
|
||||
{
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels())
|
||||
{
|
||||
if ("Nimbus".equals(info.getName()))
|
||||
{
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException ex)
|
||||
{
|
||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (InstantiationException ex)
|
||||
{
|
||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IllegalAccessException ex)
|
||||
{
|
||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (javax.swing.UnsupportedLookAndFeelException ex)
|
||||
{
|
||||
java.util.logging.Logger.getLogger(ChatView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
//</editor-fold>
|
||||
//</editor-fold>
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the form */
|
||||
java.awt.EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
new ChatView().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton btnSend;
|
||||
private javax.swing.JButton btnSetClient;
|
||||
private javax.swing.JButton btnSetServer;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JLabel lblStatusDialog;
|
||||
private javax.swing.JLabel lblType;
|
||||
private javax.swing.JTextField txtField;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
26
src/ohmlogger/MyFormatter.java
Normal file
26
src/ohmlogger/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 ohmlogger;
|
||||
|
||||
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/ohmlogger/OhmLogger.java
Normal file
54
src/ohmlogger/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 ohmlogger;
|
||||
|
||||
|
||||
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);
|
||||
fh.setFormatter(new MyFormatter());
|
||||
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
src/ohmlogger/OhmLogger.properties
Normal file
4
src/ohmlogger/OhmLogger.properties
Normal file
@ -0,0 +1,4 @@
|
||||
#Level
|
||||
LOG_LEVEL=INFO
|
||||
#Log-Datei
|
||||
LOG_DATEI=../logOHM.txt
|
4
src/ohmlogger/logger.properties
Normal file
4
src/ohmlogger/logger.properties
Normal file
@ -0,0 +1,4 @@
|
||||
#Level
|
||||
LOG_LEVEL=ALL
|
||||
#Log-Datei
|
||||
LOG_DATEI=
|
Loading…
x
Reference in New Issue
Block a user