{"id":265162,"date":"2015-09-08T12:52:07","date_gmt":"2015-09-08T08:52:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=265162"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=265162","title":{"rendered":"\u041f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u043b\u043e\u0433\u0435\u0440 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 psr\/log. \u0414\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445"},"content":{"rendered":"<p>       \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0435\u0431\u0435, \u0447\u0442\u043e \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, cms \u0438\u043b\u0438 \u0441\u0430\u043c\u043e\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u043c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0432\u0437\u044f\u0442\u044c \u0443\u0436\u0435 <a href=\"https:\/\/packagist.org\/search\/?q=log\">\u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 <\/a>, \u043d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442. \u0418 \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u044b \u0435\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e PSR-3 <a href=\"https:\/\/packagist.org\/packages\/psr\/log\">psr\/log<\/a>. <a name=\"habracut\"><\/a> \u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0430\u043c\u043e\u0433\u043e PSR-3 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"http:\/\/svyatoslav.biz\/misc\/psr_translation\/#_PSR-3\">\u0442\u0443\u0442<\/a>.<\/p>\n<p>  \u0427\u0442\u043e \u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u0443\u043c\u0435\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442:  <\/p>\n<ul>\n<li>\u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c\u0441\u044f<\/li>\n<li>\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u043e\u0433\u0438 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0441\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e<\/li>\n<\/ul>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430:<\/p>\n<pre><code class=\"php\">&lt;?php namespace Logger;  use Psr\\Log\\AbstractLogger; use Psr\\Log\\LoggerInterface;  \/**  * Class Logger  *\/ class Logger extends AbstractLogger implements LoggerInterface { \t\/** \t * @inheritdoc \t *\/ \tpublic function log($level, $message, array $context = []) \t{ \t\t\/\/\u0442\u0443\u0442 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \t} } <\/code><\/pre>\n<p>  \u041c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u0444\u0430\u0439\u043b, \u0431\u0430\u0437\u0443 \u0438 \u043f\u0440. \u043f\u0440\u044f\u043c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <b>log()<\/b>, \u043d\u043e \u043d\u0430\u043c \u0436\u0435 \u043d\u0443\u0436\u043d\u043e \u0433\u0438\u0431\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u043c\u044b \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0440\u043e\u0443\u0442\u044b.<\/p>\n<p>  \u0412\u043e\u0442 \u0442\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0448\u0435\u0433\u043e \u043b\u043e\u0433-\u0440\u043e\u0443\u0442\u0430:<\/p>\n<pre><code class=\"php\">&lt;?php namespace Logger;  use Psr\\Log\\AbstractLogger; use Psr\\Log\\LoggerInterface;  \/**  * Class Route  *\/ abstract class Route extends AbstractLogger implements LoggerInterface { \t\/** \t * @var bool \u0412\u043a\u043b\u044e\u0447\u0435\u043d \u043b\u0438 \u0440\u043e\u0443\u0442 \t *\/ \tpublic $isEnable = true; } <\/code><\/pre>\n<p>  \u041f\u043e\u043a\u0430 \u0432 \u043d\u0451\u043c \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <b>$isEnable<\/b>, \u043d\u043e \u0432\u0441\u043a\u043e\u0440\u0435 \u043c\u044b \u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043c. <\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430 \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u043e\u0443\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u043e\u0433\u0438 \u0432 \u0444\u0430\u0439\u043b:<\/p>\n<pre><code class=\"php\">&lt;?php namespace Logger\\Routes;  use Logger\\Route;  \/**  * Class FileRoute  *\/ class FileRoute extends Route { \t\/** \t * @var string \u041f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \t *\/ \tpublic $filePath; \t\/** \t * @var string \u0428\u0430\u0431\u043b\u043e\u043d \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \t *\/ \tpublic $template = &quot;{date} {level} {message} {context}&quot;;  \t\/** \t * @inheritdoc \t *\/ \tpublic function __construct(array $attributes = []) \t{ \t\tparent::__construct($attributes);  \t\tif (!file_exists($this-&gt;filePath)) \t\t{ \t\t\ttouch($this-&gt;filePath); \t\t} \t}  \t\/** \t * @inheritdoc \t *\/ \tpublic function log($level, $message, array $context = []) \t{ \t\tfile_put_contents($this-&gt;filePath, trim(strtr($this-&gt;template, [ \t\t\t'{date}' =&gt; $this-&gt;getDate(), \t\t\t'{level}' =&gt; $level, \t\t\t'{message}' =&gt; $message, \t\t\t'{context}' =&gt; $this-&gt;contextStringify($context), \t\t])) . PHP_EOL, FILE_APPEND); \t} } <\/code><\/pre>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0410 \u0442\u0430\u043a, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043b\u043e\u0433\u0438 \u0432 \u0411\u0414<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php namespace Logger\\Routes;  use PDO; use Logger\\Route;  \/**  * Class DatabaseRoute  *  * \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:  *  * CREATE TABLE default_log (  *      id integer PRIMARY KEY,  *      date date,  *      level varchar(16),  *      message text,  *      context text  * );  *\/ class DatabaseRoute extends Route { \t\/** \t * @var string Data Source Name \t * @see http:\/\/php.net\/manual\/en\/pdo.construct.php \t *\/ \tpublic $dsn; \t\/** \t * @var string \u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0411\u0414 \t *\/ \tpublic $username; \t\/** \t * @var string \u041f\u0430\u0440\u043e\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0411\u0414 \t *\/ \tpublic $password; \t\/** \t * @var string \u0418\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b \t *\/ \tpublic $table;  \t\/** \t * @var PDO \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0411\u0414 \t *\/ \tprivate $connection;  \t\/** \t * @inheritdoc \t *\/ \tpublic function __construct(array $attributes = []) \t{ \t\tparent::__construct($attributes); \t\t$this-&gt;connection = new PDO($this-&gt;dsn, $this-&gt;username, $this-&gt;password); \t}  \t\/** \t * @inheritdoc \t *\/ \tpublic function log($level, $message, array $context = []) \t{ \t\t$statement = $this-&gt;connection-&gt;prepare( \t\t\t'INSERT INTO ' . $this-&gt;table . ' (date, level, message, context) ' . \t\t\t'VALUES (:date, :level, :message, :context)' \t\t); \t\t$statement-&gt;bindParam(':date', $this-&gt;getDate()); \t\t$statement-&gt;bindParam(':level', $level); \t\t$statement-&gt;bindParam(':message', $message); \t\t$statement-&gt;bindParam(':context', $this-&gt;contextStringify($context)); \t\t$statement-&gt;execute(); \t} } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u0443 \u0438\u043b\u0438 \u0432 syslog<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">&lt;?php namespace Logger\\Routes;  use Logger\\Route; use Psr\\Log\\LogLevel;  \/**  * Class SyslogRoute  *\/ class SyslogRoute extends Route { \t\/** \t * @var string \u0428\u0430\u0431\u043b\u043e\u043d \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \t *\/ \tpublic $template = &quot;{message} {context}&quot;;  \t\/** \t * @inheritdoc \t *\/ \tpublic function log($level, $message, array $context = []) \t{ \t\t$level = $this-&gt;resolveLevel($level); \t\tif ($level === null) \t\t{ \t\t\treturn; \t\t}  \t\tsyslog($level, trim(strtr($this-&gt;template, [ \t\t\t'{message}' =&gt; $message, \t\t\t'{context}' =&gt; $this-&gt;contextStringify($context), \t\t]))); \t} \t\/** \t * \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0443\u0440\u043e\u0432\u043d\u044f \u043b\u043e\u0433\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0434\u043b\u044f syslog() \t * \t * @see http:\/\/php.net\/manual\/en\/function.syslog.php \t * @param $level \t * @return string \t *\/ \tprivate function resolveLevel($level) \t{ \t\t$map = [ \t\t\tLogLevel::EMERGENCY =&gt; LOG_EMERG, \t\t\tLogLevel::ALERT =&gt; LOG_ALERT, \t\t\tLogLevel::CRITICAL =&gt; LOG_CRIT, \t\t\tLogLevel::ERROR =&gt; LOG_ERR, \t\t\tLogLevel::WARNING =&gt; LOG_WARNING, \t\t\tLogLevel::NOTICE =&gt; LOG_NOTICE, \t\t\tLogLevel::INFO =&gt; LOG_INFO, \t\t\tLogLevel::DEBUG =&gt; LOG_DEBUG, \t\t]; \t\treturn isset($map[$level]) ? $map[$level] : null; \t} } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0432\u043e \u0432\u0441\u0435\u0445 \u043d\u0430\u0448\u0438\u0445 \u043b\u043e\u0433\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0435\u0434\u0438\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u0442\u044b, \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0440\u043e\u0443\u0442\u0430 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 <b>getDate()<\/b> \u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <b>$dateFormat<\/b>, \u0430 \u0442\u0430\u043a \u0436\u0435 \u043c\u0435\u0442\u043e\u0434 <b>contextStringify()<\/b> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \u0442\u0440\u0435\u0442\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043c\u0435\u0442\u043e\u0434\u0430 <b>log()<\/b>:<\/p>\n<pre><code class=\"php\">&lt;?php namespace Logger;  use DateTime; use Psr\\Log\\AbstractLogger; use Psr\\Log\\LoggerInterface;  \/**  * Class Route  *\/ abstract class Route extends AbstractLogger implements LoggerInterface { \t\/** \t * @var bool \u0412\u043a\u043b\u044e\u0447\u0435\u043d \u043b\u0438 \u0440\u043e\u0443\u0442 \t *\/ \tpublic $isEnable = true; \t\/** \t * @var string \u0424\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u0442\u044b \u043b\u043e\u0433\u043e\u0432 \t *\/ \tpublic $dateFormat = DateTime::RFC2822;  \t\/** \t * \u0422\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u0430\u0442\u0430 \t * \t * @return string \t *\/ \tpublic function getDate() \t{ \t\treturn (new DateTime())-&gt;format($this-&gt;dateFormat); \t}  \t\/** \t * \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 $context \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \t * \t * @param array $context \t * @return string \t *\/ \tpublic function contextStringify(array $context = []) \t{ \t\treturn !empty($context) ? json_encode($context) : null; \t} } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u0448 Logger \u0434\u0440\u0443\u0436\u0438\u0442\u044c \u0441 \u0440\u043e\u0443\u0442\u0430\u043c\u0438:<\/p>\n<pre><code class=\"php\">&lt;?php namespace Logger;  use SplObjectStorage; use Psr\\Log\\AbstractLogger; use Psr\\Log\\LoggerInterface;  \/**  * Class Logger  *\/ class Logger extends AbstractLogger implements LoggerInterface { \t\/** \t * @var SplObjectStorage \u0421\u043f\u0438\u0441\u043e\u043a \u0440\u043e\u0443\u0442\u043e\u0432 \t *\/ \tpublic $routes;  \t\/** \t * \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \t *\/ \tpublic function __construct() \t{ \t\t$this-&gt;routes = new SplObjectStorage(); \t}  \t\/** \t * @inheritdoc \t *\/ \tpublic function log($level, $message, array $context = []) \t{ \t\tforeach ($this-&gt;routes as $route) \t\t{ \t\t\tif (!$route instanceof Route) \t\t\t{ \t\t\t\tcontinue; \t\t\t} \t\t\tif (!$route-&gt;isEnable) \t\t\t{ \t\t\t\tcontinue; \t\t\t} \t\t\t$route-&gt;log($level, $message, $context); \t\t} \t} } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <b>log()<\/b> \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043e\u043d \u043f\u0440\u043e\u0431\u0435\u0436\u0438\u0442\u0441\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c \u0440\u043e\u0443\u0442\u0430\u043c \u0438 \u0432\u044b\u0437\u043e\u0432\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <b>log()<\/b> \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043d\u0430\u0448\u0438\u0445 \u0440\u043e\u0443\u0442\u043e\u0432 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <a href=\"http:\/\/php.net\/manual\/ru\/class.splobjectstorage.php\">SplObjectStorage<\/a> \u0438\u0437 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 PHP. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0432\u0430\u043d\u0438\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"php\">$logger = new Logger\\Logger();  $logger-&gt;routes-&gt;attach(new Logger\\Routes\\FileRoute([ \t'isEnable' =&gt; true, \t'filePath' =&gt; 'data\/default.log', ])); $logger-&gt;routes-&gt;attach(new Logger\\Routes\\DatabaseRoute([ \t'isEnable' =&gt; true, \t'dsn' =&gt; 'sqlite:data\/default.sqlite', \t'table' =&gt; 'default_log', ])); $logger-&gt;routes-&gt;attach(new Logger\\Routes\\SyslogRoute([ \t'isEnable' =&gt; true, ]));  $logger-&gt;info(&quot;Info message&quot;); $logger-&gt;alert(&quot;Alert message&quot;); $logger-&gt;error(&quot;Error message&quot;); $logger-&gt;debug(&quot;Debug message&quot;); $logger-&gt;notice(&quot;Notice message&quot;); $logger-&gt;warning(&quot;Warning message&quot;); $logger-&gt;critical(&quot;Critical message&quot;); $logger-&gt;emergency(&quot;Emergency message&quot;); <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u043e\u0443\u0442\u043e\u0432 \u043f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u043c \u043a\u043b\u0430\u0441\u0441 Route:<\/p>\n<pre><code class=\"php\">&lt;?php namespace Logger;  use DateTime; use Psr\\Log\\AbstractLogger; use Psr\\Log\\LoggerInterface;  \/**  * Class Route  *\/ abstract class Route extends AbstractLogger implements LoggerInterface { \t\/** \t * @var bool \u0412\u043a\u043b\u044e\u0447\u0435\u043d \u043b\u0438 \u0440\u043e\u0443\u0442 \t *\/ \tpublic $isEnable = true; \t\/** \t * @var string \u0424\u043e\u0440\u043c\u0430\u0442 \u0434\u0430\u0442\u044b \u043b\u043e\u0433\u043e\u0432 \t *\/ \tpublic $dateFormat = DateTime::RFC2822;  \t\/** \t * \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \t * \t * @param array $attributes \u0410\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0440\u043e\u0443\u0442\u0430 \t *\/ \tpublic function __construct(array $attributes = []) \t{ \t\tforeach ($attributes as $attribute =&gt; $value) \t\t{ \t\t\tif (property_exists($this, $attribute)) \t\t\t{ \t\t\t\t$this-&gt;{$attribute} = $value; \t\t\t} \t\t} \t}  \t\/** \t * \u0422\u0435\u043a\u0443\u0449\u0430\u044f \u0434\u0430\u0442\u0430 \t * \t * @return string \t *\/ \tpublic function getDate() \t{ \t\treturn (new DateTime())-&gt;format($this-&gt;dateFormat); \t}  \t\/** \t * \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 $context \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 \t * \t * @param array $context \t * @return string \t *\/ \tpublic function contextStringify(array $context = []) \t{ \t\treturn !empty($context) ? json_encode($context) : null; \t} } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0438 \u0432\u0441\u0451, \u0442\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043b\u043e\u0433\u0435\u0440\u0430 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u043f\u0440\u0435\u0434\u0435\u043b, \u0432\u0435\u0434\u044c \u043c\u043e\u0436\u043d\u043e \u0435\u0449\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u043b\u043e\u0433\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u043e\u0443\u0442 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u043e\u0443\u0442\u044b \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u043b\u043e\u0433\u043e\u0432 \u0432 logstash \u0438\u043b\u0438 \u043f\u043e ssh \u043d\u0430 \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u0443\u044e \u043c\u0430\u0448\u0438\u043d\u0443 \u0438 \u043c\u043d\u043e\u0433\u043e\u0435 \u043c\u043d\u043e\u0433\u043e\u0435 \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432\u0441\u0451 \u0432 \u0433\u043e\u0442\u043e\u0432\u043e\u043c \u0432\u0438\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430 github <a href=\"https:\/\/github.com\/alexmgit\/psrlogger\">https:\/\/github.com\/alexmgit\/psrlogger<\/a>       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/266423\/\"> http:\/\/habrahabr.ru\/post\/266423\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0435\u0431\u0435, \u0447\u0442\u043e \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, cms \u0438\u043b\u0438 \u0441\u0430\u043c\u043e\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u043c, \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0434\u043b\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0432\u0437\u044f\u0442\u044c \u0443\u0436\u0435 <a href=\"https:\/\/packagist.org\/search\/?q=log\">\u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 <\/a>, \u043d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442. \u0418 \u043f\u0438\u0441\u0430\u0442\u044c \u043c\u044b \u0435\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e PSR-3 <a href=\"https:\/\/packagist.org\/packages\/psr\/log\">psr\/log<\/a>. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-265162","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=265162"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265162\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=265162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=265162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=265162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}