summaryrefslogtreecommitdiff
path: root/vendor/fguillot/simpleLogger/src/SimpleLogger
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/fguillot/simpleLogger/src/SimpleLogger')
-rw-r--r--vendor/fguillot/simpleLogger/src/SimpleLogger/Base.php89
-rw-r--r--vendor/fguillot/simpleLogger/src/SimpleLogger/File.php48
-rw-r--r--vendor/fguillot/simpleLogger/src/SimpleLogger/Logger.php94
-rw-r--r--vendor/fguillot/simpleLogger/src/SimpleLogger/Stderr.php25
-rw-r--r--vendor/fguillot/simpleLogger/src/SimpleLogger/Stdout.php25
-rw-r--r--vendor/fguillot/simpleLogger/src/SimpleLogger/Syslog.php72
6 files changed, 0 insertions, 353 deletions
diff --git a/vendor/fguillot/simpleLogger/src/SimpleLogger/Base.php b/vendor/fguillot/simpleLogger/src/SimpleLogger/Base.php
deleted file mode 100644
index c662a1a3..00000000
--- a/vendor/fguillot/simpleLogger/src/SimpleLogger/Base.php
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-
-namespace SimpleLogger;
-
-use Psr\Log\AbstractLogger;
-use Psr\Log\LogLevel;
-
-/**
- * Base class for loggers
- *
- * @package SimpleLogger
- * @author Frédéric Guillot
- */
-abstract class Base extends AbstractLogger
-{
- /**
- * Minimum log level for the logger
- *
- * @access private
- * @var string
- */
- private $level = LogLevel::DEBUG;
-
- /**
- * Set minimum log level
- *
- * @access public
- * @param string $level
- */
- public function setLevel($level)
- {
- $this->level = $level;
- }
-
- /**
- * Get minimum log level
- *
- * @access public
- * @return string
- */
- public function getLevel()
- {
- return $this->level;
- }
-
- /**
- * Dump to log a variable (by example an array)
- *
- * @param mixed $variable
- */
- public function dump($variable)
- {
- $this->log(LogLevel::DEBUG, var_export($variable, true));
- }
-
- /**
- * Interpolates context values into the message placeholders.
- *
- * @access protected
- * @param string $message
- * @param array $context
- * @return string
- */
- protected function interpolate($message, array $context = array())
- {
- // build a replacement array with braces around the context keys
- $replace = array();
-
- foreach ($context as $key => $val) {
- $replace['{' . $key . '}'] = $val;
- }
-
- // interpolate replacement values into the message and return
- return strtr($message, $replace);
- }
-
- /**
- * Format log message
- *
- * @param mixed $level
- * @param string $message
- * @param array $context
- * @return string
- */
- protected function formatMessage($level, $message, array $context = array())
- {
- return '['.date('Y-m-d H:i:s').'] ['.$level.'] '.$this->interpolate($message, $context).PHP_EOL;
- }
-}
diff --git a/vendor/fguillot/simpleLogger/src/SimpleLogger/File.php b/vendor/fguillot/simpleLogger/src/SimpleLogger/File.php
deleted file mode 100644
index be3bfa85..00000000
--- a/vendor/fguillot/simpleLogger/src/SimpleLogger/File.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-namespace SimpleLogger;
-
-use RuntimeException;
-
-/**
- * File logger
- *
- * @package SimpleLogger
- * @author Frédéric Guillot
- */
-class File extends Base
-{
- /**
- * Filename
- *
- * @access protected
- * @var string
- */
- protected $filename = '';
-
- /**
- * Setup logger configuration
- *
- * @param string $filename Output file
- */
- public function __construct($filename)
- {
- $this->filename = $filename;
- }
-
- /**
- * Logs with an arbitrary level.
- *
- * @param mixed $level
- * @param string $message
- * @param array $context
- */
- public function log($level, $message, array $context = array())
- {
- $line = $this->formatMessage($level, $message, $context);
-
- if (file_put_contents($this->filename, $line, FILE_APPEND | LOCK_EX) === false) {
- throw new RuntimeException('Unable to write to the log file.');
- }
- }
-}
diff --git a/vendor/fguillot/simpleLogger/src/SimpleLogger/Logger.php b/vendor/fguillot/simpleLogger/src/SimpleLogger/Logger.php
deleted file mode 100644
index dc340cde..00000000
--- a/vendor/fguillot/simpleLogger/src/SimpleLogger/Logger.php
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-
-namespace SimpleLogger;
-
-use Psr\Log\AbstractLogger;
-use Psr\Log\LoggerAwareInterface;
-use Psr\Log\LoggerInterface;
-use Psr\Log\LogLevel;
-
-/**
- * Handler for multiple loggers
- *
- * @package SimpleLogger
- * @author Frédéric Guillot
- */
-class Logger extends AbstractLogger implements LoggerAwareInterface
-{
- /**
- * Logger instances
- *
- * @access private
- */
- private $loggers = array();
-
- /**
- * Get level priority
- *
- * @param mixed $level
- * @return integer
- */
- public function getLevelPriority($level)
- {
- switch ($level) {
- case LogLevel::EMERGENCY:
- return 600;
- case LogLevel::ALERT:
- return 550;
- case LogLevel::CRITICAL:
- return 500;
- case LogLevel::ERROR:
- return 400;
- case LogLevel::WARNING:
- return 300;
- case LogLevel::NOTICE:
- return 250;
- case LogLevel::INFO:
- return 200;
- }
-
- return 100;
- }
-
- /**
- * Sets a logger instance on the object
- *
- * @param LoggerInterface $logger
- * @return null
- */
- public function setLogger(LoggerInterface $logger)
- {
- $this->loggers[] = $logger;
- }
-
- /**
- * Proxy method to the real loggers
- *
- * @param mixed $level
- * @param string $message
- * @param array $context
- * @return null
- */
- public function log($level, $message, array $context = array())
- {
- foreach ($this->loggers as $logger) {
- if ($this->getLevelPriority($level) >= $this->getLevelPriority($logger->getLevel())) {
- $logger->log($level, $message, $context);
- }
- }
- }
-
- /**
- * Dump variables for debugging
- *
- * @param mixed $variable
- */
- public function dump($variable)
- {
- foreach ($this->loggers as $logger) {
- if ($this->getLevelPriority(LogLevel::DEBUG) >= $this->getLevelPriority($logger->getLevel())) {
- $logger->dump($variable);
- }
- }
- }
-}
diff --git a/vendor/fguillot/simpleLogger/src/SimpleLogger/Stderr.php b/vendor/fguillot/simpleLogger/src/SimpleLogger/Stderr.php
deleted file mode 100644
index 2573177e..00000000
--- a/vendor/fguillot/simpleLogger/src/SimpleLogger/Stderr.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-namespace SimpleLogger;
-
-/**
- * Stderr logger
- *
- * @package SimpleLogger
- * @author Frédéric Guillot
- */
-class Stderr extends Base
-{
- /**
- * Logs with an arbitrary level.
- *
- * @param mixed $level
- * @param string $message
- * @param array $context
- * @return null
- */
- public function log($level, $message, array $context = array())
- {
- file_put_contents('php://stderr', $this->formatMessage($level, $message, $context), FILE_APPEND);
- }
-}
diff --git a/vendor/fguillot/simpleLogger/src/SimpleLogger/Stdout.php b/vendor/fguillot/simpleLogger/src/SimpleLogger/Stdout.php
deleted file mode 100644
index 82d181b2..00000000
--- a/vendor/fguillot/simpleLogger/src/SimpleLogger/Stdout.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-namespace SimpleLogger;
-
-/**
- * Stdout logger
- *
- * @package SimpleLogger
- * @author Frédéric Guillot
- */
-class Stdout extends Base
-{
- /**
- * Logs with an arbitrary level.
- *
- * @param mixed $level
- * @param string $message
- * @param array $context
- * @return null
- */
- public function log($level, $message, array $context = array())
- {
- file_put_contents('php://stdout', $this->formatMessage($level, $message, $context), FILE_APPEND);
- }
-}
diff --git a/vendor/fguillot/simpleLogger/src/SimpleLogger/Syslog.php b/vendor/fguillot/simpleLogger/src/SimpleLogger/Syslog.php
deleted file mode 100644
index c4e26a7a..00000000
--- a/vendor/fguillot/simpleLogger/src/SimpleLogger/Syslog.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-namespace SimpleLogger;
-
-use RuntimeException;
-use Psr\Log\LogLevel;
-
-/**
- * Syslog Logger
- *
- * @package SimpleLogger
- * @author Frédéric Guillot
- */
-class Syslog extends Base
-{
- /**
- * Setup Syslog configuration
- *
- * @param string $ident Application name
- * @param int $facility See http://php.net/manual/en/function.openlog.php
- */
- public function __construct($ident = 'PHP', $facility = LOG_USER)
- {
- if (! openlog($ident, LOG_ODELAY | LOG_PID, $facility)) {
- throw new RuntimeException('Unable to connect to syslog.');
- }
- }
-
- /**
- * Get syslog priority according to Psr\LogLevel
- *
- * @param mixed $level
- * @return integer
- */
- public function getSyslogPriority($level)
- {
- switch ($level) {
- case LogLevel::EMERGENCY:
- return LOG_EMERG;
- case LogLevel::ALERT:
- return LOG_ALERT;
- case LogLevel::CRITICAL:
- return LOG_CRIT;
- case LogLevel::ERROR:
- return LOG_ERR;
- case LogLevel::WARNING:
- return LOG_WARNING;
- case LogLevel::NOTICE:
- return LOG_NOTICE;
- case LogLevel::INFO:
- return LOG_INFO;
- }
-
- return LOG_DEBUG;
- }
-
- /**
- * Logs with an arbitrary level.
- *
- * @param mixed $level
- * @param string $message
- * @param array $context
- * @return null
- */
- public function log($level, $message, array $context = array())
- {
- $syslogPriority = $this->getSyslogPriority($level);
- $syslogMessage = $this->interpolate($message, $context);
-
- syslog($syslogPriority, $syslogMessage);
- }
-}