PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.2.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.2.3
3.8.0 3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 All 112 releases
← All changes | includes/Core/Importer/LogHelper.php +37 -9 3.0.6 → 3.2.3 View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2
3 3 namespace Templately\Core\Importer;
4 4
5 +use Templately\Core\Importer\Utils\LogHandler;
5 6 use Templately\Utils\Helper;
6 7
7 8 trait LogHelper {
8 9 private $log_types = [
@@ -35,14 +36,10 @@
35 36 }
36 37
37 38 public function sse_message( $data ) {
38 39 // Log the data into debug log file
39 - $this->debug_log( $data );
40 + $this->sse_log_file( $data );
40 41
41 - $log = get_transient( 'templately_fsi_log' ) ?: [];
42 - $log[] = $data;
43 - set_transient( 'templately_fsi_log', $log, 15 * MINUTE_IN_SECONDS );
44 -
45 42 if(Helper::should_flush()){
46 43 echo "event: message\n";
47 44 echo 'data: ' . wp_json_encode( $data ) . "\n\n";
48 45
@@ -49,15 +46,44 @@
49 46 // Extra padding.
50 47 echo esc_html( ':' . str_repeat( ' ', 2048 ) . "\n\n" );
51 48
52 49 flush();
50 + if (ob_get_level() > 0) {
51 + ob_flush();
52 + }
53 53 }
54 - else if($data['action'] === 'complete' || $data['action'] === 'error'){
55 - wp_send_json( $data );
56 - }
54 + // else {
55 + // $log = get_option( 'templately_fsi_log' ) ?: [];
56 + // $log[] = $data;
57 + // update_option( 'templately_fsi_log', $log );
58 + // }
59 + // else if($data['action'] === 'complete' || $data['action'] === 'downloadComplete' || $data['action'] === 'error'){
60 + // wp_send_json( $data );
61 + // }
57 62 }
58 63
59 64 /**
65 + * Printing Error Logs in debug.log file or in option.
66 + *
67 + * @param mixed $log
68 + * @return void
69 + */
70 + public function sse_log_file( $log ){
71 + $request_params = FullSiteImport::_get_session_data();
72 +
73 + if (is_array($log)) {
74 + $log['timestamp'] = date('Y-m-d H:i:s');
75 + }
76 +
77 + if (isset($request_params['log_type']) && $request_params['log_type'] == 'file') {
78 + LogHandler::sse_log_file($log);
79 + } else {
80 + $_log = get_option('templately_fsi_log') ?: [];
81 + $_log[] = $log;
82 + update_option('templately_fsi_log', $_log, false);
83 + }
84 + }
85 + /**
60 86 * Printing Error Logs in debug.log file.
61 87 *
62 88 * @param mixed $log
63 89 * @return void
@@ -63,12 +89,14 @@
63 89 * @return void
64 90 */
65 91 public function debug_log( $log ){
66 92 if ( defined('TEMPLATELY_EVENT_LOG') && TEMPLATELY_EVENT_LOG === true ) {
93 +
67 94 if ( is_array( $log ) || is_object( $log ) ) {
68 95 error_log( print_r( $log, true ) );
69 - } else {
96 + } else if($log) {
70 97 error_log( $log );
71 98 }
99 +
72 100 }
73 101 }
74 102 }