| 1 |
<?php |
| 2 |
|
| 3 |
if(class_exists('RabbitLoader_21_Tab_Log')){ |
| 4 |
#it seems we have a conflict |
| 5 |
return; |
| 6 |
} |
| 7 |
|
| 8 |
class RabbitLoader_21_Tab_Log { |
| 9 |
|
| 10 |
public static function init(){ |
| 11 |
add_settings_section( |
| 12 |
'rabbitloader_section_log', |
| 13 |
' ', |
| 14 |
'', |
| 15 |
'rabbitloader-log' |
| 16 |
); |
| 17 |
} |
| 18 |
|
| 19 |
public static function echoMainContent(){ |
| 20 |
do_settings_sections( 'rabbitloader-log' ); |
| 21 |
|
| 22 |
$activity_log = get_transient( 'rabbitloader_trans_activity_log' ); |
| 23 |
if(!is_array($activity_log)){ |
| 24 |
$http = RabbitLoader_21_Core::callGETAPI('report/activity_log?limit=10', $apiError, $apiMessage); |
| 25 |
if(!empty($http['body']['data']['activity_log'])){ |
| 26 |
$activity_log = $http['body']['data']['activity_log']; |
| 27 |
} |
| 28 |
set_transient('rabbitloader_trans_activity_log', $activity_log, 300); |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
?> |
| 34 |
<div class="" style="max-width: 1160px; margin:40px auto;"> |
| 35 |
<div class="row mb-4"> |
| 36 |
<div class="col"> |
| 37 |
<div class="bg-white rounded p-4"> |
| 38 |
<div class="row"> |
| 39 |
<div class="col-12 text-secondary"> |
| 40 |
<h5 class="mt-0">Recent Log Messages</h5> |
| 41 |
<span class="mb-4 d-block">These are system generated log messages to get more insights on things running under the hood.</span> |
| 42 |
</div> |
| 43 |
<div class="col-12"> |
| 44 |
<?php |
| 45 |
if(empty($activity_log)){ |
| 46 |
_e('Everything looks good. No messages to show here.'); |
| 47 |
}else{ |
| 48 |
$alert_class = ['I'=>'info', 'W'=>'warning', 'E'=>'danger']; |
| 49 |
$alert_icon = ['I'=>'info', 'W'=>'warning', 'E'=>'bell']; |
| 50 |
foreach($activity_log as $log){ |
| 51 |
printf('<div class="alert alert-%s" role="alert"><span class="d-block "><span class="dashicons dashicons-%s align-middle"></span> %s UTC</span><hr><p class="fs-6 mb-0">%s</p></div>', $alert_class[$log['ll']], $alert_icon[$log['ll']], date('F j, Y h:i A', strtotime($log['create_time'])), $log['fd']); |
| 52 |
} |
| 53 |
} |
| 54 |
?> |
| 55 |
</div> |
| 56 |
</div> |
| 57 |
</div> |
| 58 |
</div> |
| 59 |
</div> |
| 60 |
</div> |
| 61 |
<?php |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
?> |