add( $timestamp, $level, $message, $tag, $context ); } /** * Add a log entry to chosen file. * * @param int $timestamp Log timestamp. * @param string $level emergency|alert|critical|error|warning|notice|info|debug * @param string $message Log message. * @param string $tag Log tag. Useful for filtering and sorting. * @param array $context { * Context will be serialized and stored in database. * } * * @return bool True if write was successful. */ public static function add( $timestamp, $level, $message, $tag, $context ) { global $wpdb; $insert = array( 'timestamp' => date( 'Y-m-d H:i:s', $timestamp ), 'level' => WC_Log_Levels::get_level_severity( $level ), 'message' => $message, 'tag' => $tag, ); $format = array( '%s', '%d', '%s', '%s', '%s', // possible serialized context ); if ( ! empty( $context ) ) { $insert['context'] = serialize( $context ); } return false !== $wpdb->insert( "{$wpdb->prefix}woocommerce_log", $insert, $format ); } /** * Clear all logs from the DB. * * @return bool True if flush was successful. */ public static function flush() { global $wpdb; return $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}woocommerce_log" ); } }