title: Monolog messages called multiple times
body: <p>I am having a wrapper class for monolog as below</p>
  <p><strong>log.php</strong></p>
  <pre><code>&lt;?php
  
  namespace Plugin\Core;
  
  use Monolog\Handler\StreamHandler;
  use Monolog\Level;
  use Monolog\Logger;
  use Monolog\Formatter\LineFormatter;
  
  class Log
  {
  
      private $logger;
  
      private $path;
  
      public function __construct($name = 'wpmatrimony', $path = NULL)
      {
     
          if(empty($path)){
              
              $path = WPMATRIMONY_PLUGIN_DIR.'./logs/'.$name.'.log';
  
          }
  
          $this-&gt;path = $path;
  
          $this-&gt;logger = new Logger($name);
  
          $this-&gt;logger-&gt;setTimezone(new \DateTimeZone('ASIA/KOLKATA'));
  
      }
  
      private function handler($level){
  
          // https://stackoverflow.com/questions/13968967/how-not-to-show-last-bracket-in-a-monolog-log-line
  
          $handler = new StreamHandler($this-&gt;path, $level);
  
          $dateFormat = &quot;d-m-Y H:i:s&quot;;
  
          $handler-&gt;setFormatter(new LineFormatter(NULL, $dateFormat, false, true));
  
          return $handler;
  
      }
  
      public function info($log){
  
          $this-&gt;logger-&gt;pushHandler($this-&gt;handler(Level::Info));
  
          $this-&gt;logger-&gt;info($log);
  
      }
  
      public function debug($log){
  
          $this-&gt;logger-&gt;pushHandler($this-&gt;handler(Level::Debug));
  
          $this-&gt;logger-&gt;debug($log);
  
      }
  
      public function error($log){
  
          $this-&gt;logger-&gt;pushHandler($this-&gt;handler(Level::Error));
  
          $this-&gt;logger-&gt;error($log);
  
      }
  
      public function warning($log){
  
          $this-&gt;logger-&gt;pushHandler($this-&gt;handler(Level::Warning));
  
          $this-&gt;logger-&gt;warning($log);
  
      }
  
      public function notice($log){
  
          $this-&gt;logger-&gt;pushHandler($this-&gt;handler(Level::Notice));
  
          $this-&gt;logger-&gt;notice($log);
  
      }
  
  
      public function critical($log){
  
          $this-&gt;logger-&gt;pushHandler($this-&gt;handler(Level::Critical));
  
          $this-&gt;logger-&gt;critical($log);
  
      }
  
      public function alert($log){
  
          $this-&gt;logger-&gt;pushHandler($this-&gt;handler(Level::Alert));
  
          $this-&gt;logger-&gt;alert($log);
  
      }
  
      public function emergency($log){
  
          $this-&gt;logger-&gt;pushHandler($this-&gt;handler(Level::Emergency));
  
          $this-&gt;logger-&gt;emergency($log);
  
      }
  
  }
  </code></pre>
  <p>This is working fine. But i am getting the logs increment for each lines, in below case</p>
  <pre><code>$log = new Log('test-monolog');
  $log-&gt;debug('debug');
  $log-&gt;info('info');
  $log-&gt;warning('warning');
  </code></pre>
  <p><strong>Actual Output</strong></p>
  <pre><code>[30-07-2022 09:41:50] test-monolog.DEBUG: debug  
  [30-07-2022 09:41:50] test-monolog.INFO: info  
  [30-07-2022 09:41:50] test-monolog.INFO: info  
  [30-07-2022 09:41:50] test-monolog.WARNING: warning  
  [30-07-2022 09:41:50] test-monolog.WARNING: warning  
  [30-07-2022 09:41:50] test-monolog.WARNING: warning 
  </code></pre>
  <p><strong>Expected Output</strong></p>
  <pre><code>[30-07-2022 09:47:22] test-monolog.DEBUG: debug  
  [30-07-2022 09:47:22] test-monolog.INFO: info  
  [30-07-2022 09:47:22] test-monolog.WARNING: warning
  </code></pre>
  <p>If my code is like below, i am getting expected output</p>
  <pre><code> $log = new Log('test-monolog');
   $log-&gt;debug('debug');
   $log = new Log('test-monolog');
   $log-&gt;info('info');
   $log = new Log('test-monolog');
   $log-&gt;warning('warning');
  </code></pre>
  <p>How can i avoid calling the Log class multiple times?</p>