Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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

by poj (Abbot)
on Feb 11, 2016 at 09:45 UTC ( #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? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2022-05-25 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?