amattu2 / event-logger
一个轻量级的PHP 7+基本事件消息记录器,简化了编写和生成带时间戳事件的负担。
v1.0.0
2023-03-09 22:38 UTC
This package is not auto-updated.
Last update: 2024-09-21 04:05:38 UTC
README
这是一个基本的PHP事件记录器类,用于编写基于HTML的事件日志。
用法
addEvent
此函数用于添加新的事件日志。可选地覆盖默认的时间戳(当前时间)。
/** * Add a new event to the log * * @param string $text event content * @param ?DateTime $timestamp event timestamp * @return boolean success * @author Alec M. */ public function addEvent(string $text, \DateTime $timestamp = null) : bool
getStartTime
此函数返回第一个添加的事件的时间戳的确切DateTime。
/** * Return first event timestamp * * @return \DateTime */ public function getStartTime() : \DateTime
getEndTime
此函数返回最后一次将事件添加到日志的DateTime时间戳。
/** * Return last event timestamp * * @return \DateTime */ public function getEndTime() : \DateTime
getEvents
这返回事件日志的数组。
/** * Return collection of events * * @return array */ public function getEvents() : array
getEventsTable
这返回格式化为HTML表格的事件日志。可选地覆盖事件的DateTime格式。
/** * Return the event list as a HTML table * * @param string $date_format DateTime format string * @return string HTML table */ public function getEventsTable(string $date_format = "Y-m-d G:i:s") : string
要求 & 依赖项
PHP 7+ 或更高版本