Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Proper way to create packages and re-usable code?

by poj (Abbot)
on Feb 11, 2016 at 09:45 UTC ( [id://1154931]=note: print w/replies, xml ) Need Help??


in reply to Proper way to create packages and re-usable code?

How does/should this work when you have split the code into packages?

That's explained in Log::Log4perl

.. you can retrieve logger objects anywhere in the code. Note that there's no need to carry any logger references around with your functions and methods. You can get a logger anytime via a singleton mechanism:
#!/usr/bin/perl use strict; package MyModule; use Log::Log4perl; my $log = Log::Log4perl->get_logger("MyModule"); sub doit { $log->info("I'm doing it !"); } package main; use Log::Log4perl ':easy'; Log::Log4perl->easy_init(); $log->info("Asking doit"); MyModule->doit();
poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1154931]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-25 13:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found