Re: POE, log4perl and sqlite
[email protected] (Rocco Caputo) Thu, 18 Oct 2012 09:19:43 -0400
| Newsgroups | perl.poe |
|---|---|
| Message-ID | <[email protected]> |
On Oct 18, 2012, at 07:58, Antti Linno wrote: > First of all, I have to apologise. Still no pastebin. We have to apologize, too. You're asking questions about code we cannot = see. This impairs our ability to provide satisfying answers. > But a general tree would be something like that. >=20 > Main POE module, imported submodule1, imported submodule2. All 3 > modules open the same logger conf and use the same sqlite file to > append the log. Theoretically the log file could be locked, if all 3 > or even 2 modules try to write at the same time. No. As others have said, POE doesn't pre-empt. Under ordinary = circumstances, we expect all three modules to call Log::Log4perl = sequentially rather than concurrently. We don't expect Log::Log4perl = suffer from lock contention. It's very likely that something extraordinary is happening as a result = of code we cannot see. Others have already outlined the most likely = reasons for the symptoms you described. I hope you understand that's = the best we can do without your cooperation. > What would be the nice and tidy thing to do? Initialize logger in main > POE module and pass it to submodules? That's such a good question that Log::Log4perl already answers it: "Why Log::Log4perl->get_logger and not Log::Log4perl->new? We don't want = to create a new object every time. Usually in OO-Programming, you create = an object once and use the reference to it to call its methods. However, = this requires that you pass around the object to all functions and the = last thing we want is pollute each and every function/method we're using = with a handle to the Logger: [example omitted] "Instead, if a function/method wants a reference to the logger, it just = calls the Logger's static get_logger($category) method to obtain a = reference to the one and only possible logger object of a certain = category. That's called a singleton if you're a Gamma fan." That quote is from = http://search.cpan.org/~mschilli/Log-Log4perl-1.38/lib/Log/Log4perl.pm#Ini= tialize_via_a_configuration_file --=20 Rocco Caputo <[email protected]>=