[李景山php]每天laravel-20160920|Writer-2
来源:互联网 发布:全球云计算大会 上海 编辑:程序博客网 时间:2024/05/16 07:02
//2016-07-20 /** * Register a file log handler. * * @param string $path * @param string $level * @return void */ public function useFiles($path, $level = 'debug') { $this->monolog->pushHandler($handler = new StreamHandler($path, $this->parseLevel($level))); $handler->setFormatter($this->getDefaultFormatter());// set formatter by get the default format }// Register a file log handler. /** * Register a daily file log handler. * * @param string $path * @param int $days * @param string $level * @return void */ public function useDailyFiles($path, $days = 0, $level = 'debug') { $this->monolog->pushHandler( $handler = new RotatingFileHandler($path, $days, $this->parseLevel($level)) ); $handler->setFormatter($this->getDefaultFormatter()); }// a daily file file log handler /** * Register a Syslog handler. * * @param string $name * @param string $level * @return \Psr\Log\LoggerInterface */ public function useSyslog($name = 'laravel', $level = 'debug') { return $this->monolog->pushHandler(new SyslogHandler($name, LOG_USER, $level)); }// get a register Sys log Handler /** * Register an error_log handler. * * @param string $level * @param int $messageType * @return void */ public function useErrorLog($level = 'debug', $messageType = ErrorLogHandler::OPERATING_SYSTEM) { $this->monolog->pushHandler( $handler = new ErrorLogHandler($messageType, $this->parseLevel($level)) ); $handler->setFormatter($this->getDefaultFormatter()); } /** * Register a new callback handler for when a log event is triggered. * * @param \Closure $callback * @return void * * @throws \RuntimeException */ public function listen(Closure $callback) { if (! isset($this->dispatcher)) { throw new RuntimeException('Events dispatcher has not been set.'); } $this->dispatcher->listen('illuminate.log', $callback); }//listen is a method // register a new callback handler for when a log event is triggered. /** * Fires a log event. * * @param string $level * @param string $message * @param array $context * @return void */ protected function fireLogEvent($level, $message, array $context = []) { // If the event dispatcher is set, we will pass along the parameters to the // log listeners. These are useful for building profilers or other tools // that aggregate all of the log messages for a given "request" cycle. if (isset($this->dispatcher)) { $this->dispatcher->fire('illuminate.log', compact('level', 'message', 'context')); }// isset this->dispatcher // dispatcher fire }//fire like start it,more use fire log Event /** * Format the parameters for the logger. * * @param mixed $message * @return mixed */ protected function formatMessage($message) { if (is_array($message)) {//determine array ? return var_export($message, true);// output } elseif ($message instanceof Jsonable) {// a instanceof this Jsonable return $message->toJson();//to Json } elseif ($message instanceof Arrayable) {// instanceof Arrayable return var_export($message->toArray(), true);// output } return $message;// other output message }//format the parameters for the logger /** * Parse the string level into a Monolog constant. * * @param string $level * @return int * * @throws \InvalidArgumentException */ protected function parseLevel($level) { if (isset($this->levels[$level])) { return $this->levels[$level]; }// isset throw new InvalidArgumentException('Invalid log level.');//throw Exception }// change string to int like constant. /** * Get the underlying Monolog instance. * * @return \Monolog\Logger */ public function getMonolog() { return $this->monolog; }//a big get ,magic get /** * Get a defaut Monolog formatter instance. * * @return \Monolog\Formatter\LineFormatter */ protected function getDefaultFormatter() { return new LineFormatter(null, null, true, true); }// a default format is a line Format /** * Get the event dispatcher instance. * * @return \Illuminate\Contracts\Events\Dispatcher */ public function getEventDispatcher() { return $this->dispatcher; }//get dispatcher /** * Set the event dispatcher instance. * * @param \Illuminate\Contracts\Events\Dispatcher $dispatcher * @return void */ public function setEventDispatcher(Dispatcher $dispatcher) { $this->dispatcher = $dispatcher; }// set the dispatcher.}
0 0
- [李景山php]每天laravel-20160920|Writer-2
- [李景山php]每天laravel-20160919|Writer-1
- [李景山php]每天laravel-20160828|McryptEncrypter-2
- [李景山php]每天laravel-20160902|Dispatcher-2
- [李景山php]每天laravel-20160911|FileSystem-2
- [李景山php]每天laravel-20160915|FileSystemManager-2
- [李景山php]每天laravel-20161002|Validator.php-2
- [李景山php]每天laravel-20161019|RedirectResponse.php-2
- [李景山php]每天laravel-20161021|Request.php-2
- [李景山php]每天laravel-20161103|CompilerEngine.php-2
- [李景山php]每天laravel-20161118|ConnectionFatory.php-2
- [李景山php]每天laravel-20161130|BelongsToMany.php-2
- [李景山php]每天laravel-20160922|RedisServicProvider.php
- [李景山php]每天laravel-20160923|Hub.php
- [李景山php]每天laravel-20160924|PiplineServiceProvider.php
- [李景山php]每天laravel-20160925|Pipeline.php
- [李景山php]每天laravel-20160926|DatabasePresenceVerifier.php
- [李景山php]每天laravel-20160927|Factory.php
- html头文件中的 content = "IE=edge,chrome=1"
- win64 Python下安装PIL出错解决
- 嵌入式开发第10天(高级议题,C语言结束)
- 关于Oracle的事务
- HDU 5725 Game
- [李景山php]每天laravel-20160920|Writer-2
- 长度是怎样炼成的(一)
- 悼念512汶川大地震遇难同胞——老人是真饿了
- 如何用消息系统避免分布式事务?
- emwin的进度条控件
- 面对异议,你为什么会觉得无力争辩?
- 编程实现双链表的建立、插入、删除、求长、逆置
- Opencv中在图片上显示文本
- 【杭电5053】the Sum of Cube