Re: POE, log4perl and sqlite
Rocco Caputo <[email protected]> Fri, 19 Oct 2012 08:46:12 -0400
| Newsgroups | gmane.comp.lang.perl.poe |
|---|---|
| Message-ID | <[email protected]> |
Every module seems to be re-initializing your logger. I don't know if = it's harmful in your situation, but it's not recommended. Wherever you = call Log::Log4perl::init($log_conf) try = Log::Log4perl->init_once($log_conf) instead. See: = http://search.cpan.org/~mschilli/Log-Log4perl-1.38/lib/Log/Log4perl.pm#Ini= tialize_once_and_only_once Offhand I don't see anything else that would lock your log database. = Maybe another program is locking it in SELECT? If that's true, the = queries are taking too long for the bot to wait. Maybe you could = optimize the table indexes so the queries complete in time. --=20 Rocco Caputo <[email protected]> On Oct 19, 2012, at 07:04, Antti Linno wrote: > Thank you for your kind interest. >=20 > The pastebins: >=20 > log4perl.conf http://pastebin.com/nY4twgjS > main file http://pastebin.com/ruYsu2qt > application logic http://pastebin.com/hMyyBJ0U > database interaction http://pastebin.com/Cq7d4geK >=20 > As you can see, all the perl files are logging, main and application > import database functions. I have snipped the application and database > somewhat, but you could see the main structure and how I am doing the > logging. >=20 > Greetings. >=20 > On Thu, Oct 18, 2012 at 4:19 PM, Rocco Caputo <[email protected]> = wrote: >> On Oct 18, 2012, at 07:58, Antti Linno wrote: >>=20 >>> First of all, I have to apologise. Still no pastebin. >>=20 >> We have to apologize, too. You're asking questions about code we = cannot see. This impairs our ability to provide satisfying answers. >>=20 >>> 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. >>=20 >> 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. >>=20 >> 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. >>=20 >>> What would be the nice and tidy thing to do? Initialize logger in = main >>> POE module and pass it to submodules? >>=20 >> That's such a good question that Log::Log4perl already answers it: >>=20 >> "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: >>=20 >> [example omitted] >>=20 >> "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." >>=20 >> 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]>