I am using the Medoo database framework, directly add log to the database, use the need to import the Medoo file.
log.php
<?PHPrequire(‘.. /dao/medoo.php ');functionLogi ($tag,$message) {input ("I",$tag,$message);}functionLogE ($tag,$message) {input ("E",$tag,$message);}functionLOGW ($tag,$message) {input ("W",$tag,$message);}functionLOGD ($tag,$message) {input ("D",$tag,$message);}functionInput$type,$tag,$message) { $db=NewMedoo (NULL); $db->insert ("En_log",Array ( "L_ID" = uuid (), "l_type" =$type, "l_tag" =$tag, "l_msg" =$message));}/** * Generate UUID*/functionUuid$prefix= ' '){ $chars=MD5(uniqid(Mt_rand(),true)); $uuid=substr($chars, 0,8). ‘-‘; $uuid.=substr($chars, 8,4). ‘-‘; $uuid.=substr($chars, 12,4). ‘-‘; $uuid.=substr($chars, 16,4). ‘-‘; $uuid.=substr($chars, 20,12); return $prefix.$uuid;}?>
Here is the MySQL database structure, I use the UUID to make table primary key
CREATE TABLE ' en_log ' ( ' l_id ' char (null, nullDEFAULT Current_ TIMESTAMP on UPDATE current_timestamp, ' L_type ' enum (NULL, ' L_tag ' char ( NULL,null, KEY (' l_id ') ENGINE DEFAULT Charset=utf8;
I know the PHP print log certainly has a better way to put it.