in reply to Logging to web page with Mojolicious and strict
Maybe declare our $logLine; in your main perl script (index.mojo) and then access the variable in each of the files you require with its fully qualified name which will be $main::logLine ?
However, if it was me, I would create a logging class and instantiate a global log object. Which will have api like log("hello") and toString() and toHTML(). In this way I expand my logging capabilities as much as I like with just one single global variable (the log object). And when I feel like, I modify all my subs to take just one additional parameter which will be the log object. No matter how I modify the log object in the future, I will not need a second global variable and I will not need to modify my subs for a second time...
bw, bliako
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Logging to web page with Mojolicious and strict
by TieUpYourCamel (Scribe) on Sep 13, 2019 at 19:56 UTC | |
by bliako (Abbot) on Sep 14, 2019 at 09:00 UTC | |
by TieUpYourCamel (Scribe) on Sep 16, 2019 at 12:19 UTC | |
by TieUpYourCamel (Scribe) on Sep 16, 2019 at 15:36 UTC |