Subject: Developers of Sympa
List archive
Re: [sympa-developpers] [sympa-commits] sympa[10705] trunk/src/lib/Sympa/Instruction.pm: [dev] load dependencies at runtime, and only if needed
- From: Guillaume Rousse <address@concealed>
- To: address@concealed
- Subject: Re: [sympa-developpers] [sympa-commits] sympa[10705] trunk/src/lib/Sympa/Instruction.pm: [dev] load dependencies at runtime, and only if needed
- Date: Fri, 06 Jun 2014 16:24:34 +0200
Le 06/06/2014 08:45, IKEDA Soji a écrit :
Guillaume,There is no 'log failed' event, because logging never fails... More exactly, Sys::Syslog::syslog() always return 1 (it is hardcoded in XS code), and the underlying native C syslog function has void as return type. So trying to catch a log failure is quite futile.
On Wed, 28 May 2014 13:18:52 +0200
Guillaume Rousse <address@concealed> wrote:
Le 27/05/2014 15:54, IKEDA Soji a écrit :
Hi,That would seem merely hiding the dust behind the carpet, at the cost of
How about using Class::Autouse?
additional external code moreover.
I prefer to adresse the actual problem at the source, and find some way
to pass the relevant parameters directly. Just passing a Sympa::Site
instance, or using a global $main::site instance, for instance, would be
enough in most cases.
I wish to keep "logs_failed" notification feature in log module.
Log module looks being used by most of other modules including Site.That would a fine solution, indeed, excepted for the previous issue.
So, I at first did like:
use Sympa::Site;
use Sympa::Logger;
my $logger = Sympa::Logger->instance;
$logger->set_options(
log_level => Sympa::Site->log_level,
# Other options...
fault_handler => sub {
Sympa::Site->send_notify_to_listmaster('logs_failed');
}
);
# The first speech
$logger->do_log('notice', 'MYDAEMON started');
Sympa::Logger need not use Sympa::Site explicitly. Alternatively,
if syslog is broken, Sympa::Logger::do_log() would call fault_handler.
...However, this solution is essentially not neccessary. AnytimeThat's wrong in testing scenarios, and potentially in multiple tools from the src/bin directory that may require only a subset of Sympa codebase in memory.
when do_log() is called, inevitablly Sympa::Site has been loaded.
Sympa::Logger can freely call send_notify_to_listmaster() by itself.
More generally, assuming a package has been transitively loaded in memory by current package depencies is a fragile assumption, and won't survive refactoring very long.
I think the situation is same on task instruction. When the task ist/instruction.t, for instance.
running, is it possible that the module like Sympa::List has not been
loaded?
--
Guillaume Rousse
INRIA, Direction des systèmes d'information
Domaine de Voluceau
Rocquencourt - BP 105
78153 Le Chesnay
Tel: 01 39 63 58 31
Attachment:
smime.p7s
Description: Signature cryptographique S/MIME
-
Re: [sympa-developpers] [sympa-commits] sympa[10705] trunk/src/lib/Sympa/Instruction.pm: [dev] load dependencies at runtime, and only if needed,
IKEDA Soji, 06/06/2014
-
Re: [sympa-developpers] [sympa-commits] sympa[10705] trunk/src/lib/Sympa/Instruction.pm: [dev] load dependencies at runtime, and only if needed,
Guillaume Rousse, 06/06/2014
-
Re: [sympa-developpers] [sympa-commits] sympa[10705] trunk/src/lib/Sympa/Instruction.pm: [dev] load dependencies at runtime, and only if needed,
IKEDA Soji, 06/06/2014
- Re: [sympa-developpers] [sympa-commits] sympa[10705] trunk/src/lib/Sympa/Instruction.pm: [dev] load dependencies at runtime, and only if needed, Guillaume Rousse, 06/16/2014
-
Re: [sympa-developpers] [sympa-commits] sympa[10705] trunk/src/lib/Sympa/Instruction.pm: [dev] load dependencies at runtime, and only if needed,
IKEDA Soji, 06/06/2014
-
Re: [sympa-developpers] [sympa-commits] sympa[10705] trunk/src/lib/Sympa/Instruction.pm: [dev] load dependencies at runtime, and only if needed,
Guillaume Rousse, 06/06/2014
Archive powered by MHonArc 2.6.19+.