Looking for a clever way of logging

Posted by OctavioOlguin on 08-Mar-2016 13:42

Having trouble to dbug some procedures that remotelly connect to appserver, so i came to this way of  logging.

I remeber have seen a better way.  Hoping someone to point me in that direction.

&SCOPED-DEFINE logging YES 
DEFINE STREAM dbg.
&scoped-define logit OUTPUT STREAM dbg TO value(SESSION:TEMP-DIRECTORY + "dbg.txt") APPEND. ~
PUT STREAM dbg SKIP(1) NOW  "  ".

&scoped-define CloseIt OUTPUT STREAM dbg CLOSE.


...


   &if {&logging} &then
      {&logit}
      PUT STREAM dbg "Getting connection".
      {&CloseIt}        
   &endif
    
    GET-KEY-VALUE SECTION "CONNECTION" KEY "AppServerUser"        VALUE pUsuario.
    GET-KEY-VALUE SECTION "CONNECTION" KEY "SucursalAppServer"    VALUE t1Char.
    

All Replies

Posted by Brian K. Maher on 08-Mar-2016 13:46

On the AppServer just use MESSAGE <whatever> VIEW-AS ALERT-BOX and it will show up in the AppServer server log file.

Posted by OctavioOlguin on 08-Mar-2016 13:49

Thanks... but I'm just begging to debug at the client side... wan't to see why the program crahses the session of the users and statrts over...

Some funcition on the initializing procedures of a .W is crashing the entire user's session.

PS:  and on the server I use

MESSAGE "this....".     //wihout the view-as....

Posted by Tony on 08-Mar-2016 14:44

You can turn on client side tracing by including this in the client startup command

-clientlog c:\tmp\mylog.lg -logginglevel 4 -logentrytypes 4GLTrace:4 -debugalert


You may need to enable debugging for the openedge environment for both the client and the appserver with proDebugEnable -enable-all

There is also KB article 000001305 you could look at.

If you're on widows, there is a GUI version of the unix 'tail' command called 'Wintail'. Saved my mind a number of times.

Cheers, Tony.

Posted by OctavioOlguin on 08-Mar-2016 14:46

Thanks!!!!

Way more clever than reinventing the wheel!!!

Posted by Peter Judge on 08-Mar-2016 19:30

I like using LOG-MANAGER too. You can write your own messages via the WRITE-MESSAGE() method. It's not perfect but it works nicely in a log of situations.
 

Posted by Patrick Tingen on 09-Mar-2016 04:03

We use a combination of PUBLISH and the LOG-MANAGER. At the start of each program we do a call to initiate the logger. This logger is started persistently and checks in a database table whether it is active or not for that particular program. If it is active, it will subscribe to the "debugMessage" event. Inside our programs we have lots of publishes like this:

PUBLISH "debugMessage" (1, "some interesting message here").

Whenever the logger receives this, it writes the string and the level number it receives to the log-manager. Works like a charm and the good part is that you do not have to change and recompile your program when you want to switch on debugging. You can do this even in production. As a matter of fact, we do. By default all logging is off in production, but if needed we can turn it on. Having PUBLISH statements without a receiving procedure listening (which is the normal situation) is hardly noticable in terms of performance.

Posted by Peter Judge on 09-Mar-2016 08:44

Patrick,

Do you have a similar pattern for OOABL-based programs?

Posted by gus on 09-Mar-2016 08:58

why would you have to it a different way for oo ???

ignorant minds want to know.

Posted by Peter Judge on 09-Mar-2016 09:04

I don't want to. But I have to, since alas PUBLISH() isn't supported from OO.
 
publish 'foo' ('bar').
 
Results in compiler indigestion
---------------------------
Check Syntax
---------------------------
Syntax check:
PUBLISH statement may only be used in a class file with the FROM phrase. (12906)
---------------------------
OK  
---------------------------
 
You can get around this with Malarkey
       def var hProc as handle.
       hProc = session:first-procedure.
             
       publish 'foo' from hProc ('bar').
             
Or some other intermediary, but it shouldn't require it.
 
 

Posted by Keith Sudbury on 09-Mar-2016 09:20

For OO.. it seems the event model would work if you wanted to mirror the example.

I usually just make a static utility class/methods that all of the other classes can use with log management and other useful things (tablestats, indexstats, turing on/off the profiler, etc).

Posted by OctavioOlguin on 09-Mar-2016 13:21

Thanks Patrick, and all....

Wonder if you could provide a little detailed howto on the scheme you mention?  It sounds very solid. and us very weak can get strength on the way.

This thread is closed