There are many ways to approach this - yours seems to be one reasonable method.
Another way might be to use a centralised logging module which used a singleton approach to do something similar. The advantage here is that by delaying the openlog to the first call, you may go through an entire execution without ever opening the log - which may or may not be of significance. There would only be one call to openlog in your entire program because they would all go through MyLogger::logthis() - which would open the log if it wasn't already open. Then, using the magic of singletons, the DESTROY method would close it, or you could use the END block as above to detect if the log was opened, and, if so, then close it.
I suppose a method that maps closest to how you developed procedurally would have the advantage of being a philosophy close to what you're used to, so my question is - before you tried the magic of OO, how did you use syslog?
Update: The above was written before the real problem appeared in Zarathustra's update. The error message seems to say that your syslog.h doesn't have a macro required for this to work - that's a compile-time problem, not a run-time problem. Does your non-module use of syslog work on this same machine? What platform is it?
In reply to Re: Sys::Syslog in OOP Module
by Tanktalus
in thread Sys::Syslog in OOP Module
by Zarathustra
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |