aboutsummaryrefslogtreecommitdiff
path: root/src/simpleapdu/DirtyLogger.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/simpleapdu/DirtyLogger.java')
-rw-r--r--src/simpleapdu/DirtyLogger.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/simpleapdu/DirtyLogger.java b/src/simpleapdu/DirtyLogger.java
new file mode 100644
index 0000000..69e5e65
--- /dev/null
+++ b/src/simpleapdu/DirtyLogger.java
@@ -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 simpleapdu;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author xsvenda
+ */
+public class DirtyLogger {
+ FileOutputStream m_logFile;
+ boolean m_bOutputSystemOut = true;
+ public DirtyLogger(FileOutputStream logFile, boolean bOutputSystemOut) {
+ m_logFile = logFile;
+ m_bOutputSystemOut = bOutputSystemOut;
+ }
+ public void println() {
+ String logLine = "\n";
+ print(logLine);
+ }
+ public void println(String logLine) {
+ logLine += "\n";
+ print(logLine);
+ }
+ public void print(String logLine) {
+ if (m_bOutputSystemOut) {
+ System.out.print(logLine);
+ }
+ if (m_logFile != null) {
+ try {
+ m_logFile.write(logLine.getBytes());
+ } catch (IOException ex) {
+ }
+ }
+ }
+
+ void flush() {
+ try {
+ m_logFile.flush();
+ } catch (IOException ex) {
+ }
+ }
+}