Skip to content

Commit

Permalink
初始化
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangbj committed May 10, 2019
1 parent ca7a531 commit 0af0161
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ Temporary Items
# 环境文件
.uini
ErrorFiles

u.php
logs
# 缓存文件夹
update/
application/logs/
Expand Down
10 changes: 10 additions & 0 deletions dome/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
require_once '../vendor/autoload.php';

use \logger\Logger;

#设置logs根目录
define('LOG_PATH', realpath(__DIR__).DIRECTORY_SEPARATOR.'logs'.DIRECTORY_SEPARATOR); // 日志目录
Logger::i('测试字符串内容', '中文路径名/测试文件', '0');
Logger::i(array('数组内容'), 'array/res', '1');
Logger::i(array('数组内容'), 'array/res', '2');
4 changes: 3 additions & 1 deletion src/Logger.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

namespace logger;

use \Exception;

/**
* 代码日志记录类
* Class Logger
Expand Down Expand Up @@ -37,7 +39,7 @@ protected function __construct($log_file)
throw new Exception('文件名不可以是空值,并且不能包含特殊字符,如有特殊字符会被替换为下划线', '001');
}
$log_file = $this->replace_special_char($log_file);
defined('LOG_PATH') or define('LOG_PATH', realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR.'logs'.DIRECTORY_SEPARATOR); // 日志目录
defined('LOG_PATH') or define('LOG_PATH', realpath(__DIR__).DIRECTORY_SEPARATOR.'logs'.DIRECTORY_SEPARATOR); // 日志目录
$this->log_name = LOG_PATH.$log_file.date('_Y_m_d').'.log';
}

Expand Down

0 comments on commit 0af0161

Please sign in to comment.