[unixODBC-support] driver logging

Eric Sharkey sharkey at netrics.com
Tue Mar 1 18:33:03 GMT 2005

> Well, I tried to replicate what the MS DM does, those two att's control 
> DM logging. What the driver can do, is to look at the DM variable 
> ODBCSharedTraceFlag and use that to turn its logging on and off, this 
> again is the same as under windows AFAIK

I see.  It would need to check this before every logging attempt,
I guess.  But there's no way to determine the log file name is there?

The only other way I see to do it would be to read an ini value
with SQLGetPrivateProfileString to see if the driver should be logging
and where, but I don't see how to do this without having a DSN,
which isn't available until SQL(Driver)Connect is called.  Ideally,
the driver would like to start logging as soon as AllocEnv is called.

Is there any way to read driver specific entries from odbcinst.ini
from within AllocEnv?  Hmm.  It looks like the PostgreSQL driver has a
hard coded value of "PostgreSQL" and looks at that section in the
odbcinst.ini.  Maybe I'll just do that.

> >What is the advantage of storing log messages in memory?
> Well, I have to admit, I inhereited the logging code from peter, and saw 
> this was what it did, but I am unsure what will break outside of the dm 
> if I change this, as I found it was using this storage in other things,

I think it should be ok to adjust logPushMsg to not store anything
in RAM iff hLog->nMaxMsgs == 0.  This would allow current apps to
continue functioning as they do now, and new apps to request zero
storage space at log open time and just write log messages to disk
if a log file is defined.

> Yes, but not all platforms have a vsnprintf/vfprintf, thats (if I 
> remember) why it was done that way.

Most do.  For those that don't I think it's better to provide an
implementation rather than not use these functions.  This is what we
do for our database.


More information about the unixODBC-support mailing list