/**
* 自定义日志log
* @param [type] $log_content [内容]
* @param string
k
e
y
p
[
文件名
]
∗
@
r
e
t
u
r
n
[
t
y
p
e
]
[
d
e
s
c
r
i
p
t
i
o
n
]
∗
u
s
e
∗
l
o
g
:
:
m
y
l
o
g
(
s
p
r
i
n
t
f
(
"
删除产品:
u
i
d
:
∗
/
p
u
b
l
i
c
s
t
a
t
i
c
f
u
n
c
t
i
o
n
m
y
l
o
g
(
keyp [文件名] * @return [type] [description] * use * log::mylog(sprintf("删除产品:uid:%s,bsid:%s,plat_id:%s", 88888, 111, 1), 'deleteProduct-' . date('Y-m-d') . '.log'); */ public static function mylog(
keyp[文件名]∗@return[type][description]∗use∗log::mylog(sprintf("删除产品:uid:∗/publicstaticfunctionmylog(log_content, $keyp = “”)
{
$max_size = 30000000;
l
o
g
f
i
l
e
n
a
m
e
=
E
n
v
:
:
g
e
t
(
′
r
u
n
t
i
m
e
p
a
t
h
′
)
.
′
l
o
g
/
′
.
d
a
t
e
(
′
Y
−
m
−
d
′
)
;
i
f
(
!
f
i
l
e
e
x
i
s
t
s
(
log_filename = Env::get('runtime_path') . 'log/' . date('Y-m-d'); if (!file_exists(
logfilename=Env::get(′runtimepath′).′log/′.date(′Y−m−d′);if(!fileexists(log_filename)) {
mkdir($log_filename, 0777, true);
}
$log_filename = Env::get(‘runtime_path’) . ‘log/’ . date(‘Y-m-d’) . ‘/’ .
k
e
y
p
.
"
.
l
o
g
"
;
i
f
(
f
i
l
e
e
x
i
s
t
s
(
keyp . ".log"; if (file_exists(
keyp.".log";if(fileexists(log_filename) && (abs(filesize($log_filename)) > KaTeX parse error: Expected '}', got 'EOF' at end of input: … rename(log_filename, dirname($log_filename) . DS . date(‘Ym-d-His’) . $keyp . “.log”);
}
$t = microtime(true);
$micro = sprintf("%06d", ($t - floor($t)) * 1000000);
$d = new \DateTime (date('Y-m-d H:i:s.' . $micro, $t));
if (is_array($log_content)) {
$log_content = JSONReturn($log_content);
}
file_put_contents($log_filename, ' ' . $d->format('Y-m-d H:i:s u') . "\r\n" . $log_content . "\r\n------------------------ --------------------------\r\n", FILE_APPEND);
}
引用