Snippets

SeanB Quick Logging

Updated by SeanB

File oQuickLog.pkg Modified

  • Ignore whitespace
  • Hide word diff
     End_Procedure
     
     Function logfile Returns String 
+        String sProgname 
+        String sLogFile
         If ((psPrivate.LogName(Self))="") Begin 
             Move (GetApplicationName(ghoApplication)) to sProgName 
             Move (sProgName+".log") to sLogFile
Updated by SeanB

File oQuickLog.pkg Modified

  • Ignore whitespace
  • Hide word diff
     End_Procedure
     
     Function logfile Returns String 
+        If ((psPrivate.LogName(Self))="") Begin 
+            Move (GetApplicationName(ghoApplication)) to sProgName 
+            Move (sProgName+".log") to sLogFile
+            Set logfile to sLogFile             
+        End
         Function_Return ( psPrivate.LogName (Self))
     End_Function
     
-    Procedure QuickLog String sText 
+    Procedure doLog String sText 
         Integer iCH 
         DateTime dtNow
     
 End_Object
 
 Procedure QuickLog Global String sMessage 
-    Send QuickLog to ghLogFile sMessage  
+    Send doLog to ghLogFile sMessage  
 End_Procedure
Created by SeanB

File oQuickLog.pkg Added

  • Ignore whitespace
  • Hide word diff
+Global_Variable Integer ghlogfile 
+Object oSimpleLog is a cObject
+    Property String psPrivate.LogName 
+    
+    Procedure Set logfile String sName 
+        String sFolder 
+        Get psHome of (phoWorkspace(oApplication)) to sFolder 
+        If ((Right(sFolder,1))<>"\") Append sFolder "\"
+        Append sFolder sName 
+        Set  psPrivate.LogName to sFolder 
+    End_Procedure
+    
+    Function logfile Returns String 
+        Function_Return ( psPrivate.LogName (Self))
+    End_Function
+    
+    Procedure QuickLog String sText 
+        Integer iCH 
+        DateTime dtNow
+    
+        Move (CurrentDateTime()) to dtNow
+        Move ("["+(String(dtNow)) +"] "+  sText) to sText 
+        
+        Get Seq_New_Channel to iCH 
+        Append_Output channel iCH (logfile(Self)) 
+        Writeln channel iCH sText 
+        Close_Output channel iCH 
+        Send Seq_Release_Channel iCH 
+    End_Procedure
+    
+    Move (Self) to ghlogfile
+End_Object
+
+Procedure QuickLog Global String sMessage 
+    Send QuickLog to ghLogFile sMessage  
+End_Procedure
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.