WC_Log_Handler_DB::add( int $timestamp, string $level, string $message, string $source, array $context )
Add a log entry to chosen file.
Description Description
Parameters Parameters
- $timestamp
-
(Required) Log timestamp.
- $level
-
(Required) emergency|alert|critical|error|warning|notice|info|debug.
- $message
-
(Required) Log message.
- $source
-
(Required) Log source. Useful for filtering and sorting.
- $context
-
(Required) Context will be serialized and stored in database.
Return Return
(bool) True if write was successful.
Source Source
File: includes/log-handlers/class-wc-log-handler-db.php
protected static function add( $timestamp, $level, $message, $source, $context ) { global $wpdb; $insert = array( 'timestamp' => date( 'Y-m-d H:i:s', $timestamp ), 'level' => WC_Log_Levels::get_level_severity( $level ), 'message' => $message, 'source' => $source, ); $format = array( '%s', '%d', '%s', '%s', '%s', // possible serialized context. ); if ( ! empty( $context ) ) { $insert['context'] = serialize( $context ); // @codingStandardsIgnoreLine. } return false !== $wpdb->insert( "{$wpdb->prefix}woocommerce_log", $insert, $format ); }