MiniLogger.st
branchjv
changeset 17906 c666c2087cc5
parent 17861 4926106dfb9c
child 17910 8d796ca8bd1d
--- a/MiniLogger.st	Thu Dec 08 18:18:15 2011 +0000
+++ b/MiniLogger.st	Fri Dec 09 23:15:57 2011 +0000
@@ -12,7 +12,7 @@
 "{ Package: 'stx:libbasic' }"
 
 Object subclass:#MiniLogger
-	instanceVariableNames:''
+	instanceVariableNames:'stream'
 	classVariableNames:'Instance'
 	poolDictionaries:''
 	category:'System-Debugging-Support'
@@ -61,6 +61,23 @@
     "Created: / 01-09-2011 / 12:26:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!MiniLogger methodsFor:'initialization'!
+
+initializeStream
+
+    Stderr isOpen ifTrue:[
+        stream := Stderr.        
+        ^self.
+    ].
+    Stdout isOpen ifTrue:[
+        stream := Stdout.
+        ^self.
+    ].
+    stream := 'smalltalkx.log' asFilename writeStream.
+
+    "Created: / 10-12-2011 / 00:11:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !MiniLogger methodsFor:'logging'!
 
 facilityOf: originator
@@ -134,7 +151,9 @@
 
     "Pricipal logging method. This mimics VM __stxLog__()"
 
-    Stderr 
+    stream isNil ifTrue:[self initializeStream].
+
+    stream
         nextPutAll: facility ? 'STX';
         space;
         nextPut:$[;
@@ -142,12 +161,13 @@
         nextPut:$];
         space.
 
-    Stderr nextPut:$(.
+    stream nextPut:$(.
     Timestamp now printOn:Stderr format:'%(year)-%(mon)-%(day) %h:%m:%s'.
-    Stderr nextPut:$).
-    Stderr space.
-    Stderr nextPutAll: message.
-    Stderr cr.
+    stream nextPut:$).
+    stream space.
+    stream nextPutAll: message.
+    stream cr.
+    stream flush.
 
     "
         Logger log:'test message' severity: #debug facility: 'TEST'
@@ -166,7 +186,7 @@
 !MiniLogger class methodsFor:'documentation'!
 
 version_SVN
-    ^ '$Id: MiniLogger.st 10688 2011-09-15 11:05:35Z vranyj1 $'
+    ^ '$Id: MiniLogger.st 10749 2011-12-09 23:15:57Z vranyj1 $'
 ! !
 
 MiniLogger initialize!