Skip to content

Commit baea309

Browse files
feat: add the new logger (#1124)
1 parent fdc42f6 commit baea309

19 files changed

+2929
-145
lines changed

css/settings.css

Lines changed: 192 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,7 @@ li.draggable-item .components-panel__body-toggle.components-button{
25932593
border-bottom: 0;
25942594
padding: 24px 0 0;
25952595
}
2596+
25962597
.fz-fallback-images {
25972598
display: flex;
25982599
flex-wrap: wrap;
@@ -2673,4 +2674,194 @@ button.feedzy-action-button {
26732674
width: 100%;
26742675
cursor: pointer;
26752676
height: unset;
2676-
}
2677+
}
2678+
2679+
/* Feedzy Logs */
2680+
.fz-logs {
2681+
padding: 10px;
2682+
margin: 10px 0;
2683+
}
2684+
2685+
.fz-logs h3 {
2686+
margin-bottom: 10px;
2687+
font-size: 1.25em;
2688+
color: #333;
2689+
}
2690+
2691+
/* Logs view container */
2692+
.fz-logs-view {
2693+
display: flex;
2694+
flex-direction: column;
2695+
gap: 2px;
2696+
}
2697+
2698+
/* Individual log container */
2699+
.fz-log-container {
2700+
display: flex;
2701+
gap: 10px;
2702+
background-color: #fff;
2703+
border: 1px solid #e0e0e0;
2704+
border-left-width: 5px;
2705+
padding: 8px 10px;
2706+
transition: background-color 0.1s ease;
2707+
font-size: 0.875em;
2708+
}
2709+
2710+
.fz-log-container:hover {
2711+
background-color: #f5f5f5;
2712+
}
2713+
2714+
/* Left section */
2715+
.fz-log-container__left {
2716+
flex: 0 0 50%;
2717+
min-width: 0;
2718+
}
2719+
2720+
/* Header with level and date */
2721+
.fx-log-container__header {
2722+
display: flex;
2723+
align-items: center;
2724+
gap: 4px;
2725+
margin-bottom: 4px;
2726+
font-size: 1.1em;
2727+
}
2728+
2729+
/* Log level styling */
2730+
.fx-log-container__header > *:first-child {
2731+
padding: 2px 6px;
2732+
border-radius: 3px;
2733+
font-size: 0.7em;
2734+
font-weight: 600;
2735+
letter-spacing: 0.3px;
2736+
text-transform: uppercase;
2737+
min-width: 50px;
2738+
text-align: center;
2739+
}
2740+
2741+
/* Date styling */
2742+
.fz-log-container__date {
2743+
color: #757575;
2744+
font-size: 0.85em;
2745+
}
2746+
2747+
/* Message styling */
2748+
.fz-log-container__message {
2749+
color: #212529;
2750+
line-height: 1.3;
2751+
word-wrap: break-word;
2752+
overflow-wrap: break-word;
2753+
font-size: 1em;
2754+
margin-top: 10px;
2755+
}
2756+
2757+
/* Right section - Context */
2758+
.fz-log-container__right {
2759+
flex: 1;
2760+
min-width: 0;
2761+
}
2762+
2763+
/* Context styling - compact */
2764+
.fz-log-container__context {
2765+
background-color: #f8f9fa;
2766+
border: 1px solid #e9ecef;
2767+
border-radius: 5px;
2768+
padding: 6px 8px;
2769+
font-family: 'Courier New', Consolas, Monaco, monospace;
2770+
font-size: 0.9em;
2771+
line-height: 1.3;
2772+
color: #495057;
2773+
white-space: pre-wrap;
2774+
word-break: break-all;
2775+
overflow-wrap: break-word;
2776+
}
2777+
2778+
.fz-log-container--error {
2779+
border-left-color: red;
2780+
}
2781+
2782+
.fz-log-container--info {
2783+
border-left-color: blue;
2784+
}
2785+
2786+
.fz-log-container--debug {
2787+
border-left-color: green;
2788+
}
2789+
2790+
.fz-log-container--warning {
2791+
border-left-color: yellow;
2792+
}
2793+
2794+
.fz-log-container--critical {
2795+
border-left-color: violet;
2796+
}
2797+
2798+
.fz-logs-header {
2799+
display: flex;
2800+
flex-direction: row;
2801+
flex-wrap: wrap;
2802+
justify-content: space-between;
2803+
margin-bottom: 1rem;
2804+
}
2805+
2806+
.fz-logs-header-actions {
2807+
display: flex;
2808+
flex-direction: row;
2809+
gap: 0.5rem;
2810+
}
2811+
2812+
.fz-logs-header-title {
2813+
display: flex;
2814+
flex-direction: row;
2815+
gap: 0.5rem;
2816+
align-items: baseline;
2817+
}
2818+
2819+
.fz-block__column {
2820+
display: flex;
2821+
flex-direction: column;
2822+
gap: 1rem;
2823+
}
2824+
2825+
.fz-group__row {
2826+
display: flex;
2827+
flex-direction: row;
2828+
gap: 1rem;
2829+
align-items: center;
2830+
}
2831+
2832+
.fz-group__left {
2833+
justify-content: flex-end;
2834+
}
2835+
2836+
.btn-outline-primary.fz-is-destructive {
2837+
color: #cc1818;
2838+
border-color: #cc1818;
2839+
}
2840+
2841+
.btn-outline-primary.fz-is-destructive:hover {
2842+
color: #cc1818;
2843+
border-color: #cc1818;
2844+
box-shadow: inset 0 0 0 1px #cc1818, inset 0 0 0 2px #f7f9fd;
2845+
background: #fdf7f7;
2846+
}
2847+
2848+
.fz-log-file-size-wrapper {
2849+
display: flex;
2850+
flex-direction: row;
2851+
gap: 0.5rem;
2852+
align-items: baseline;
2853+
}
2854+
2855+
.fz-log-file-size-wrapper .dashicons {
2856+
font-size: 1.9em;
2857+
}
2858+
2859+
.fz-hidden {
2860+
display: none;
2861+
}
2862+
2863+
.fz-quick-link-actions {
2864+
display: flex;
2865+
gap: 1rem;
2866+
margin-bottom: 20px;
2867+
}

feedzy-rss-feed.php

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ function feedzy_register_parrot( $plugins ) {
271271
* @param string $type Error type.
272272
* @param string $file File where the event occurred.
273273
* @param int $line Line number where the event occurred.
274+
*
275+
* @deprecated 5.1.0 Use Feedzy_Rss_Feeds_Log instead.
274276
*/
275277
function feedzy_themeisle_log_event( $name, $msg, $type, $file, $line ) {
276278
if ( FEEDZY_NAME === $name ) {
@@ -279,35 +281,6 @@ function feedzy_themeisle_log_event( $name, $msg, $type, $file, $line ) {
279281
}
280282
}
281283

282-
/**
283-
* Store import job errors in metadata.
284-
*
285-
* @param string $name Name.
286-
* @param string $msg Error message.
287-
* @param string $type Error type.
288-
*
289-
* @return void
290-
*/
291-
function feedzy_import_job_logs( $name, $msg, $type ) {
292-
if ( ! in_array( $type, apply_filters( 'feedzy_allowed_store_log_types', array( 'error' ) ), true ) ) {
293-
return;
294-
}
295-
if ( ! wp_doing_ajax() || wp_doing_cron() ) {
296-
return;
297-
}
298-
if ( apply_filters( 'feedzy_skip_store_error_logs', false ) ) {
299-
return;
300-
}
301-
global $themeisle_log_event;
302-
303-
if ( ! empty( $themeisle_log_event ) && count( $themeisle_log_event ) >= 200 ) {
304-
return;
305-
}
306-
307-
$themeisle_log_event[] = $msg;
308-
}
309-
add_action( 'themeisle_log_event', 'feedzy_import_job_logs', 20, 3 );
310-
311284
add_filter(
312285
'feedzy_rss_feeds_float_widget_metadata',
313286
function () {

includes/abstract/feedzy-rss-feeds-admin-abstract.php

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,8 @@ public function rest_route() {
527527
),
528528
)
529529
);
530+
531+
Feedzy_Rss_Feeds_Log::get_instance()->register_endpoints();
530532
}
531533

532534
/**
@@ -861,7 +863,14 @@ function ( $time ) use ( $cache_time ) {
861863
if ( ! $wp_filesystem->exists( $dir ) ) {
862864
$done = $wp_filesystem->mkdir( $dir );
863865
if ( false === $done ) {
864-
do_action( 'themeisle_log_event', FEEDZY_NAME, sprintf( 'Unable to create directory %s', $dir ), 'error', __FILE__, __LINE__ );
866+
Feedzy_Rss_Feeds_Log::error(
867+
sprintf( 'Unable to create SimplePie cache directory: %s', $dir ),
868+
array(
869+
'feed_url' => $feed_url,
870+
'cache' => $cache,
871+
'sc' => $sc,
872+
)
873+
);
865874
}
866875
}
867876
$feed->set_cache_location( $dir );
@@ -902,14 +911,35 @@ function ( $time ) use ( $cache_time ) {
902911
}
903912

904913
if ( ! empty( $error ) ) {
905-
do_action( 'themeisle_log_event', FEEDZY_NAME, sprintf( 'Error while parsing feed: %s', $error ), 'error', __FILE__, __LINE__ );
914+
Feedzy_Rss_Feeds_Log::error(
915+
sprintf( 'Error while parsing feed: %s', $error ),
916+
array(
917+
'feed_url' => $feed_url,
918+
'cache' => $cache,
919+
'sc' => $sc,
920+
)
921+
);
906922

907923
// curl: (60) SSL certificate problem: unable to get local issuer certificate.
908924
if ( strpos( $error, 'SSL certificate' ) !== false ) {
909-
do_action( 'themeisle_log_event', FEEDZY_NAME, sprintf( 'Got an SSL Error (%s), retrying by ignoring SSL', $error ), 'debug', __FILE__, __LINE__ );
925+
Feedzy_Rss_Feeds_Log::error(
926+
sprintf( 'Got an SSL Error (%s), retrying by ignoring SSL', $error ),
927+
array(
928+
'feed_url' => $feed_url,
929+
'cache' => $cache,
930+
'sc' => $sc,
931+
)
932+
);
910933
$feed = $this->init_feed( $feed_url, $cache, $sc, false );
911934
} elseif ( is_string( $feed_url ) || ( is_array( $feed_url ) && 1 === count( $feed_url ) ) ) {
912-
do_action( 'themeisle_log_event', FEEDZY_NAME, 'Trying to use raw data', 'debug', __FILE__, __LINE__ );
935+
Feedzy_Rss_Feeds_Log::debug(
936+
sprintf( 'Using raw data for feed: %s', $feed_url ),
937+
array(
938+
'cache' => $cache,
939+
'sc' => $sc,
940+
)
941+
);
942+
913943
$data = wp_remote_retrieve_body( wp_safe_remote_get( $feed_url, array( 'user-agent' => $default_agent ) ) );
914944
$cloned_feed->set_raw_data( $data );
915945
$cloned_feed->init();
@@ -920,7 +950,14 @@ function ( $time ) use ( $cache_time ) {
920950
$feed = $cloned_feed;
921951
}
922952
} else {
923-
do_action( 'themeisle_log_event', FEEDZY_NAME, 'Cannot use raw data as this is a multifeed URL', 'debug', __FILE__, __LINE__ );
953+
Feedzy_Rss_Feeds_Log::debug(
954+
'Cannot use raw data as this is a multifeed URL',
955+
array(
956+
'feed_url' => $feed_url,
957+
'cache' => $cache,
958+
'sc' => $sc,
959+
)
960+
);
924961
}
925962
}
926963
return $feed;
@@ -1934,7 +1971,15 @@ public function feedzy_image_encode( $img_url ) {
19341971
}
19351972

19361973
$filtered_url = apply_filters( 'feedzy_image_encode', esc_url( $img_url ), $img_url );
1937-
do_action( 'themeisle_log_event', FEEDZY_NAME, sprintf( 'Changing image URL from %s to %s', $img_url, $filtered_url ), 'debug', __FILE__, __LINE__ );
1974+
1975+
Feedzy_Rss_Feeds_Log::debug(
1976+
'Change featured image via feedzy_image_encode',
1977+
array(
1978+
'old_url' => $img_url,
1979+
'new_url' => $filtered_url,
1980+
)
1981+
);
1982+
19381983
return $filtered_url;
19391984
}
19401985

0 commit comments

Comments
 (0)