Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Judging from the source code at</p> <ul> <li><a href="https://github.com/jbroadway/analog/blob/master/examples/file.php" rel="nofollow">https://github.com/jbroadway/analog/blob/master/examples/file.php</a> and</li> <li><a href="https://github.com/jbroadway/analog/blob/master/examples/multi.php" rel="nofollow">https://github.com/jbroadway/analog/blob/master/examples/multi.php</a> and</li> <li><a href="https://github.com/jbroadway/analog/blob/master/lib/Analog/Handler/Multi.php" rel="nofollow">https://github.com/jbroadway/analog/blob/master/lib/Analog/Handler/Multi.php</a></li> </ul> <p>you should be able to use several file handlers at the same time. Try something along the lines of this:</p> <pre><code>Analog::handler(Analog\Handler\Multi::init(array( Analog::ERROR =&gt; Analog\Handler\File::init('/path/to/logs/errors.log'), Analog::WARNING =&gt; Analog\Handler\File::init('/path/to/logs/warnings.log'), Analog::DEBUG =&gt; Analog\Handler\File::init('/path/to/logs/debug.log') ))); </code></pre> <hr> <p>If you cannot make it work with <code>Analog\Handler\Multi</code>, you can still write your own <a href="http://sourcemaking.com/design_patterns/composite" rel="nofollow">Composite</a> Logger, adapting the Analog File Handler. To do that, first create an Interface defining how you want to use Loggers in your application:</p> <pre><code>interface Logger { const ERROR = 'error'; const WARNING = 'warning'; const DEBUG = 'debug'; public function log($message, $level); } </code></pre> <p>Then create the Adapter for Analog so that it satisfies the Interface:</p> <pre><code>class AnalogAdapter implements Logger { private $adaptee; public function __construct(Analog $analog) { $this-&gt;adaptee = $analog; } public function log($message, $level) { $adaptee = $this-&gt;adaptee; $adaptee::log($message, $adaptee::$level); } } </code></pre> <p>Finally, write the Composite Logger:</p> <pre><code>class CompositeLogger implements Logger { private $loggers = array; public function registerLogger(Logger $logger) { $this-&gt;loggers[] = $logger; } public function log($message, $level) { foreach ($this-&gt;loggers as $logger) { $logger-&gt;log($message, $level); } } } </code></pre> <p>Then you create your Analog file handlers and register them with the Composite:</p> <pre><code>$logger = new CompositeLogger; $logger-&gt;registerLogger( new AnalogAdapter( Analog\Handler\File::init('/path/to/logs/errors.log') ) ); // … add more Loggers in the same way $logger-&gt;log('This is a warning', Logger::WARNING); </code></pre> <p>The warning will then get written to all the registered Loggers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload