__construct() публичный Метод

public __construct ( string $name )
$name string The logging channel
Пример #1
0
 public function __construct($channel = self::CHANNEL_APPLICATION)
 {
     parent::__construct($channel);
     $this->addDatabaseHandler();
     $le = new Event($this);
     Events::dispatch('on_logger_create', $le);
 }
 public function __construct($name = 'PHPUnit', $level = 'debug')
 {
     /**
      * Filter growl notifications and send only
      * - test failures ($handerLevel = Logger::NOTICE; see GrowlHandler constructor)
      * - summary of test suites (message "Results OK ...", or "Results KO ..."
      */
     $filters = array(function ($record, $handlerLevel) {
         if ($record['level'] > $handlerLevel) {
             return true;
         }
         return preg_match('/^Results/', $record['message']) === 1;
     });
     $stream = new RotatingFileHandler(__DIR__ . DIRECTORY_SEPARATOR . 'monologTestListener.log', 0, Logger::toMonologLevel($level));
     $stream->setFilenameFormat('{filename}-{date}', 'Ymd');
     $handlers = array($stream);
     try {
         // be notified only for test suites and test failures
         $growl = new GrowlHandler(array(), Logger::NOTICE);
         $handlers[] = new CallbackFilterHandler($growl, $filters);
     } catch (\Exception $e) {
         // Growl server is probably not started
         echo $e->getMessage(), PHP_EOL, PHP_EOL;
     }
     parent::__construct($name, $handlers);
 }
Пример #3
0
 public function __construct()
 {
     $logConfig = ApiConfig::getLogConfig();
     parent::__construct($logConfig['name']);
     parent::pushHandler(new RotatingFileHandler("{$logConfig['log_path']}/info-log"), Logger::INFO);
     parent::pushHandler(new RotatingFileHandler("{$logConfig['log_path']}/info-log"), Logger::ERROR);
 }
Пример #4
0
 public function __construct($appname = "Tranquillity", $logprio = LOG_USER, $level = \Monolog\Logger::INFO)
 {
     parent::__construct($appname);
     $this->loghandler = new SyslogHandler($appname, $logprio, $level);
     $this->pushHandler($this->loghandler);
     $this->logformatter = new LineFormatter("[%level_name%] %message%");
     $this->loghandler->setFormatter($this->logformatter);
 }
Пример #5
0
 public function __construct($channel = self::CHANNEL_APPLICATION, $logLevel = MonologLogger::DEBUG)
 {
     parent::__construct($channel);
     $this->addDatabaseHandler($logLevel);
     $this->pushProcessor(new PsrLogMessageProcessor());
     $le = new Event($this);
     Events::dispatch('on_logger_create', $le);
 }
Пример #6
0
 /**
  * @param string $name The logging channel
  * @param MonologHandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc.
  * @param callable[] $processors Optional array of processors
  */
 public function __construct($name, array $handlers = [], array $processors = [])
 {
     /**
      * This is a fix for Pthreads, since that extension does not copy static variables accross threads
      */
     static::$levels = [self::DEBUG => 'DEBUG', self::INFO => 'INFO', self::NOTICE => 'NOTICE', self::WARNING => 'WARNING', self::ERROR => 'ERROR', self::CRITICAL => 'CRITICAL', self::ALERT => 'ALERT', self::EMERGENCY => 'EMERGENCY'];
     parent::__construct($name, $handlers, $processors);
 }
Пример #7
0
 /**
  * @param string $name
  * @param array  $handlers
  * @param array  $processors
  */
 function __construct($name = 'main', array $handlers = array(), array $processors = array())
 {
     /* Create new logger */
     parent::__construct($name, $handlers, $processors);
     /* Add default, console handler */
     $handler = new \Monolog\Handler\StreamHandler('php://stderr', \Monolog\Logger::DEBUG);
     $handler->setFormatter(new \Monolog\Formatter\LineFormatter("[%datetime%] [%channel%.%level_name%] -- %message%\n"));
     $this->pushHandler($handler);
 }
Пример #8
0
 public function __construct($name)
 {
     parent::__construct($name);
     $this->log = new StringBufferHandler(Logger::DEBUG);
     $this->log->setFormatter(new TaskLogFormatter());
     $this->pushHandler($this->log);
     $this->executionTime = new ExecutionTimeProcessor();
     $this->pushProcessor($this->executionTime);
 }
Пример #9
0
 /**
  * Builds Monolog\Logger data with set of handlers given in configuration file.
  * @param string $channelName Name of logging channel
  * @param Settings $settings object with json-formatted config
  * @throws InvalidArgumentException if $channelName is not a string
  * @todo check handler parameters compatibility
  */
 function __construct($channelName, Settings $settings)
 {
     if (!is_string($channelName)) {
         throw new \InvalidArgumentException('Channel name should be a string');
     }
     parent::__construct($channelName);
     $this->settings = $settings;
     $this->attachHandlers();
 }
Пример #10
0
 public function __construct(Application $application, array $handlers = [], array $processors = [], Console $consoleHandler = null)
 {
     if ($application->isDebugMode()) {
         if (null === $consoleHandler) {
             $consoleHandler = new Console($application);
         }
         $handlers[] = $consoleHandler;
     }
     parent::__construct($application->getName(), $handlers, $processors);
     $this->setApplication($application)->setConsoleHandler($consoleHandler);
 }
Пример #11
0
 public function __construct()
 {
     parent::__construct("maestro");
     $conf = Manager::getConf('maestro.logs');
     $this->baseDir = $conf['path'];
     $this->level = $conf['level'];
     $this->handler = $conf['handler'];
     $this->port = $conf['port'];
     $this->peer = $conf['peer'];
     $this->strict = $conf['strict'];
     if (empty($this->host)) {
         $this->host = $_SERVER['REMOTE_ADDR'];
     }
 }
Пример #12
0
 public function __construct($configSection)
 {
     self::factoryConstruct($configSection);
     $config = $this->getPackageConfig();
     parent::__construct($config['name']);
     $directory = dirname($config['path']);
     if (!file_exists($directory)) {
         $status = @mkdir($directory, 0777, true);
         if ($status === false) {
             $config['path'] = sys_get_temp_dir() . '/mpcmf.' . posix_getpid() . '.log';
             $this->addCritical("Log directory creation failed, use new path instead of original. New path: {$config['path']}");
         }
     } elseif (is_writable($directory)) {
         @chmod($directory, 0777);
     }
     $this->pushHandler(new StreamHandler($config['path'], $config['level']));
     MPCMF_DEBUG && $this->addDebug("New log created: {$this->configSection}");
 }
Пример #13
0
 public function __construct($name = '', $debug = false)
 {
     $options = getopt("", ['debug']);
     if (isset($options['debug'])) {
         // Default format with all the info for dev debug
         $formatter = new LineFormatter();
         $debug = true;
     } elseif (!empty($debug)) {
         // Set user debug mode
         $formatter = new LineFormatter("%level_name%: %message% %context% %extra%\n");
     } else {
         // Simple message (TODO add user readable $context)
         $formatter = new LineFormatter("%message%\n");
     }
     $errHandler = new StreamHandler('php://stderr', \Monolog\Logger::NOTICE, false);
     $level = $debug ? \Monolog\Logger::DEBUG : \Monolog\Logger::INFO;
     $handler = new StreamHandler('php://stdout', $level);
     $handler->setFormatter($formatter);
     parent::__construct($name, [$errHandler, $handler]);
 }
Пример #14
0
 /**
  * @param string             $name       The logging channel
  * @param HandlerInterface[] $handlers   Optional stack of handlers, the first one in the array is called first, etc.
  * @param callable[]         $processors Optional array of processors
  */
 public function __construct($name, array $handlers = array(), array $processors = array())
 {
     parent::__construct($name, $handlers, $processors);
     // set handler
     $elgg_log_level = _elgg_services()->logger->getLevel();
     if ($elgg_log_level == \Elgg\Logger::OFF) {
         // always log errors
         $elgg_log_level = \Elgg\Logger::ERROR;
     }
     $handler = new RotatingFileHandler(elgg_get_data_path() . 'elasticsearch/client.log', 0, $elgg_log_level);
     // create correct folder structure
     $date = date('Y/m/');
     $path = elgg_get_data_path() . "elasticsearch/{$date}";
     if (!is_dir($path)) {
         mkdir($path, 0755, true);
     }
     $handler->setFilenameFormat('{date}_{filename}', 'Y/m/d');
     $this->pushHandler($handler);
     // set logging processor
     $processor = new IntrospectionProcessor();
     $this->pushProcessor($processor);
 }
 /**
  * Console logger class constructor
  *
  * @param string $name  The logging channel
  * @param string $level The minimum logging level
  */
 public function __construct($name = 'YourLogger', $level = Logger::DEBUG)
 {
     $filterRules = array(function ($record) {
         if (!array_key_exists('operation', $record['context'])) {
             return false;
         }
         return 'printFooter' === $record['context']['operation'];
     });
     $stream = new RotatingFileHandler(__DIR__ . '/phpunit-growlhandler-php' . PHP_VERSION_ID . '.log', 30);
     $stream->setFilenameFormat('{filename}-{date}', 'Ymd');
     $console = new StreamHandler('php://stdout');
     $console->setFormatter(new LineFormatter("%message%\n", null, true));
     $filter = new FilterHandler($console);
     $handlers = array($filter, $stream);
     try {
         $options = array('resourceDir' => dirname(__DIR__) . '/vendor/pear-pear.php.net/Net_Growl/data/Net_Growl/data', 'defaultIcon' => '80/growl_phpunit.png');
         $growl = new GrowlHandler(array('name' => 'PHPUnit ResultPrinter', 'options' => $options), Logger::NOTICE);
         $growl->setFormatter(new LineFormatter("Growl for Monolog\n" . "%message%"));
         $handlers[] = new CallbackFilterHandler($growl, $filterRules);
     } catch (\Exception $e) {
         // Growl server is probably not started
     }
     parent::__construct($name, $handlers);
 }
Пример #16
0
 public function __construct($name, $logDirectory)
 {
     $this->logPath = $logDirectory . '/' . $name;
     parent::__construct($name);
     $this->configureLogger();
 }
Пример #17
0
 public function __construct($logDir)
 {
     parent::__construct('note-script');
     $this->pushHandler(new SyslogHandler($this->getName(), 'user', Monolog::ERROR));
     $this->pushHandler(new RotatingFileHandler($logDir . '/note-script.log', 10, Monolog::DEBUG));
 }
Пример #18
0
 public function __construct($name)
 {
     parent::__construct($name);
     $this->selfCounter = 0;
 }
Пример #19
0
 public function __construct($name, Logger $parentLogger)
 {
     parent::__construct($name, [], []);
     $this->parentLogger = $parentLogger;
 }
Пример #20
0
 /**
  *
  * Ctor
  * @param string $name
  * @param string $file
  * @param integer $level
  */
 public function __construct($name, $file, $level)
 {
     parent::__construct($name);
     $this->pushHandler($this->getHandler($file, $level));
 }
Пример #21
0
 /**
  * @param string $name
  * @param array $handlers
  * @param array $processors
  */
 public function __construct($name = 'Migration', array $handlers = [], array $processors = [])
 {
     parent::__construct($name, $handlers, $processors);
 }
Пример #22
0
 public function __construct($name)
 {
     $mongo = new \MongoClient(Config::$get->database->mongodb);
     parent::__construct($name, [new StreamHandler(Config::$get->logging->file), new MongoDBHandler($mongo, Config::$get->logging->mongodb->database, Config::$get->logging->mongodb->collection)]);
 }
Пример #23
0
 /**
  * @param LogFactory         $logFactory
  * @param \ShipperHQ\Common\Helper\Data $dataHelper
  * @param string             $name       The logging channel
  * @param HandlerInterface[] $handlers   Optional stack of handlers, the first one in the array is called first, etc.
  * @param callable[]         $processors Optional array of processors
  */
 public function __construct(LogFactory $logFactory, \ShipperHQ\Common\Helper\Data $dataHelper, $name, array $handlers = array(), array $processors = array())
 {
     $this->logFactory = $logFactory;
     $this->helper = $dataHelper;
     parent::__construct($name, $handlers, $processors);
 }
 public function __construct($name = 'testlogger', array $handlers = array(), array $processors = array())
 {
     parent::__construct($name, $handlers, $processors);
     $this->testHandler = new SolrReindexTest_Handler();
     $this->pushHandler($this->testHandler);
 }
 public function __construct($name = 'CloudFoundry Helper', array $processors = array())
 {
     parent::__construct($name, array(), $processors);
 }
Пример #26
0
 /**
  * @param Debugger $debugger
  */
 public function __construct(Debugger $debugger)
 {
     parent::__construct(static::class, $debugger->logHandlers(static::class));
 }
Пример #27
0
 public function __construct()
 {
     parent::__construct(APP_NAME_SHORT);
     $path = '../logs/' . APP_NAME_SHORT . 'log.log';
     $this->pushHandler(new \Monolog\Handler\StreamHandler($path, Logger::DEBUG));
 }
Пример #28
0
 /**
  * @param string $name                 The logging channel
  * @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc.
  * @param callable[] $processors       Optional array of processors
  */
 public function __construct(string $name = 'debug', array $handlers = array(), array $processors = array())
 {
     parent::__construct($name, $handlers, $processors);
 }
Пример #29
0
 /**
  * @param string $name
  * @param HandlerInterface[] $handlers
  * @param ProcessorInterface[] $processors
  */
 public function __construct($name, array $handlers, array $processors)
 {
     parent::__construct($name, $handlers, $processors);
 }
Пример #30
0
 public function __construct($name, Logger $parentLogger)
 {
     parent::__construct($name, array(), array());
     $this->parentLogger = $parentLogger;
 }