autoship_log_entry (function)
(src/logger.php) Used to add log files to the Autoship Log. Takes the source for the entry ($context) and the Log message ($message) as parameters.
Function
/** * Add a log entry. * * @param string $context The source or context for the entry * @param string $message Log message. */ function autoship_log_entry( $context, $message ){ // Allow logging to be performed separately when Autoship Logging turned off. do_action( 'autoship_before_log_entry', $context, $message ); if ( !apply_filters( 'autoship_log_entry', true, $context, $message ) ) return true; // Allow adjustments to when the log files are cleaned up. // Allows outside management like with a scheduled task ( i.e. WP Cron job ) if ( apply_filters( 'autoship_clean_logger_files', true ) ){ $keep_count = autoship_get_logs_keep_count(); autoship_keep_latest_log_files( $keep_count ); } $logfilename = autoship_get_log_filename(); $path = trailingslashit( autoship_get_logs_directory() ); $time = date_i18n( 'm-d-Y @ H:i:s' ); $entry = "[{$time}] {$context} - {$message}"; // Check for the Log Directory and Make it if it doesn't exist. if ( !autoship_maybe_setup_log_directory() ) return false; // Open / Create the Log File $log_file = fopen( $path . $logfilename, 'a'); if ( !$log_file ) { error_log( sprintf( 'Autoship Logger Exception: Failed to create or open the log file %s.', $logfilename ) ); return false; } fwrite( $log_file, $entry . "\n" ); fclose( $log_file ); // Allow for email and other actions after a log entry has been added. do_action( 'autoship_after_log_entry', $time, $entry, $context, $message ); return true; }