WC_Log_Handler

Abstract WC Log Handler Class.

Defined (1)

The class is defined in the following location(s).

/includes/abstracts/abstract-wc-log-handler.php  
  1. abstract class WC_Log_Handler implements WC_Log_Handler_Interface { 
  2.  
  3. /** 
  4. * Formats a timestamp for use in log messages. 
  5. * @param int $timestamp Log timestamp. 
  6. * @return string Formatted time for use in log entry. 
  7. */ 
  8. protected static function format_time( $timestamp ) { 
  9. return date( 'c', $timestamp ); 
  10.  
  11. /** 
  12. * Builds a log entry text from level, timestamp and message. 
  13. * @param int $timestamp Log timestamp. 
  14. * @param string $level emergency|alert|critical|error|warning|notice|info|debug 
  15. * @param string $message Log message. 
  16. * @param array $context Additional information for log handlers. 
  17. * @return string Formatted log entry. 
  18. */ 
  19. protected static function format_entry( $timestamp, $level, $message, $context ) { 
  20. $time_string = self::format_time( $timestamp ); 
  21. $level_string = strtoupper( $level ); 
  22. $entry = "{$time_string} {$level_string} {$message}"; 
  23.  
  24. return apply_filters( 'woocommerce_format_log_entry', $entry, array( 
  25. 'timestamp' => $timestamp,  
  26. 'level' => $level,  
  27. 'message' => $message,  
  28. 'context' => $context,  
  29. ) );