Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow change of debug log directory #595

Open
wants to merge 4 commits into
base: v3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/Helpers/DebugMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ public static function log( string $message ) {
return;
}

$date = date( 'Y-m-d' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
$time = date( 'H-i-s' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
$content_dir = \WP_CONTENT_DIR;
$date = date( 'Y-m-d' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
$time = date( 'H-i-s' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
$log_dir = defined( 'ANTISPAM_BEE_DEBUG_MODE_LOG_DIR' ) ? \ANTISPAM_BEE_DEBUG_MODE_LOG_DIR : \WP_CONTENT_DIR;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty long const name, would have preferred something a little shorter, e.g. strip the _MODE. But we should probably keep it consistent with ANTISPAM_BEE_DEBUG_MODE_ENABLED, so I'm fine with either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, it’s a little long 😬 Because we are not live yet and only two or three people might be using it, I would say let’s change the ANTISPAM_BEE_DEBUG_MODE_ENABLED to ANTISPAM_BEE_DEBUG and the log to ANTISPAM_BEE_DEBUG_DIR?


if ( ! is_dir( $log_dir ) ) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- Intentional debug use.
error_log( "The directory set for Antispam Bee debug logging does not exist: {$log_dir}" );
}

// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- Intentional debug use.
error_log( "[{$date} {$time}] {$message}\n", 3, "{$content_dir}/asb-debug.{$date}.log" );
error_log( "[{$date} {$time}] {$message}\n", 3, "{$log_dir}/asb-debug.{$date}.log" );
}
}