mirror of
https://gh.wpcy.net/https://github.com/discourse/wp-discourse.git
synced 2026-05-24 04:53:57 +08:00
* Don't try to add url to <head> if it's not present * Update js config and formatting for comment block and sidebar * PHP Linting * FIX: Don't auto-publish updates to existing posts. See: https://meta.discourse.org/t/disable-posting-wordpress-articles-to-discourse-when-theyre-updated/204488 * Bump version and release notes. * Fix remote-post.php linting * Update tests.yml to install svn * Re-generate comments js build
42 lines
786 B
PHP
Vendored
42 lines
786 B
PHP
Vendored
<?php
|
|
/**
|
|
* Class \Test\Logging
|
|
*
|
|
* @package WPDiscourse
|
|
*/
|
|
|
|
namespace WPDiscourse\Test;
|
|
|
|
use WPDiscourse\Logs\FileManager;
|
|
|
|
/**
|
|
* Logging methods for WPDiscourse unit tests
|
|
*/
|
|
trait Logging {
|
|
/**
|
|
* Get last line in latest log file.
|
|
*/
|
|
protected function get_last_log() {
|
|
$manager = new FileManager();
|
|
$log_files = glob( $manager->logs_dir . '/*.log' );
|
|
if ( empty( $log_files ) ) {
|
|
return '';
|
|
}
|
|
$log_file = $log_files[0];
|
|
return shell_exec( "tail -n 1 $log_file" );
|
|
}
|
|
|
|
/**
|
|
* Clear all logs.
|
|
*/
|
|
protected function clear_logs() {
|
|
$manager = new FileManager();
|
|
$log_files = glob( $manager->logs_dir . '/*.log' );
|
|
|
|
foreach ( $log_files as $file ) {
|
|
if ( is_file( $file ) ) {
|
|
unlink( $file );
|
|
}
|
|
}
|
|
}
|
|
}
|