diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php index 4e353dd0b..081f26e7d 100644 --- a/data/web/inc/functions.inc.php +++ b/data/web/inc/functions.inc.php @@ -2537,6 +2537,20 @@ function get_logs($application, $lines = false) { return $data_array; } } + if ($application == "cron-mailcow") { + if (isset($from) && isset($to)) { + $data = $redis->lRange('CRON_LOG', $from - 1, $to - 1); + } + else { + $data = $redis->lRange('CRON_LOG', 0, $lines); + } + if ($data) { + foreach ($data as $json_line) { + $data_array[] = json_decode($json_line, true); + } + return $data_array; + } + } if ($application == "postfix-mailcow") { if (isset($from) && isset($to)) { $data = $redis->lRange('POSTFIX_MAILLOG', $from - 1, $to - 1); diff --git a/data/web/js/site/debug.js b/data/web/js/site/debug.js index 512d9551e..61e7d480a 100644 --- a/data/web/js/site/debug.js +++ b/data/web/js/site/debug.js @@ -814,6 +814,66 @@ jQuery(function($){ hideTableExpandCollapseBtn('#tab-dovecot-logs', '#dovecot_log'); }); } + function draw_cron_logs() { + // just recalc width if instance already exists + if ($.fn.DataTable.isDataTable('#cron_log') ) { + $('#cron_log').DataTable().columns.adjust().responsive.recalc(); + return; + } + + var table = $('#cron_log').DataTable({ + responsive: true, + processing: true, + serverSide: false, + stateSave: true, + pageLength: log_pagination_size, + dom: "<'row'<'col-sm-12 col-md-6'f><'col-sm-12 col-md-6'l>>" + + "tr" + + "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>", + language: lang_datatables, + order: [[0, 'desc']], + initComplete: function(){ + hideTableExpandCollapseBtn('#tab-cron-logs', '#cron_log'); + }, + ajax: { + type: "GET", + url: "/api/v1/get/logs/cron", + dataSrc: function(data){ + return process_table_data(data, 'general_syslog'); + } + }, + columns: [ + { + title: lang.time, + data: 'time', + defaultContent: '', + createdCell: function(td, cellData) { + createSortableDate(td, cellData) + } + }, + { + title: lang.task, + data: 'task', + defaultContent: '' + }, + { + title: lang.priority, + data: 'priority', + defaultContent: '' + }, + { + title: lang.message, + data: 'message', + defaultContent: '', + className: 'dtr-col-md text-break' + } + ] + }); + + table.on('responsive-resize', function (e, datatable, columns){ + hideTableExpandCollapseBtn('#tab-cron-logs', '#cron_log'); + }); + } function rspamd_pie_graph() { $.ajax({ url: '/api/v1/get/rspamd/actions', @@ -1219,6 +1279,7 @@ jQuery(function($){ onVisible("[id^=ui_logs]", () => draw_ui_logs()); onVisible("[id^=sasl_logs]", () => draw_sasl_logs()); onVisible("[id^=netfilter_log]", () => draw_netfilter_logs()); + onVisible("[id^=cron_log]", () => draw_cron_logs()); onVisible("[id^=rspamd_history]", () => draw_rspamd_history()); onVisible("[id^=rspamd_donut]", () => rspamd_pie_graph()); diff --git a/data/web/json_api.php b/data/web/json_api.php index 69b236d7a..ac8963e45 100644 --- a/data/web/json_api.php +++ b/data/web/json_api.php @@ -947,6 +947,17 @@ if (isset($_GET['query'])) { } echo (isset($logs) && !empty($logs)) ? json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) : '{}'; break; + case "cron": + // 0 is first record, so empty is fine + if (isset($extra)) { + $extra = preg_replace('/[^\d\-]/i', '', $extra); + $logs = get_logs('cron-mailcow', $extra); + } + else { + $logs = get_logs('cron-mailcow'); + } + echo (isset($logs) && !empty($logs)) ? json_encode($logs, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) : '{}'; + break; case "postfix": // 0 is first record, so empty is fine if (isset($extra)) { diff --git a/data/web/templates/debug.twig b/data/web/templates/debug.twig index 867371177..c148856cb 100644 --- a/data/web/templates/debug.twig +++ b/data/web/templates/debug.twig @@ -16,6 +16,7 @@
  • +
  • {{ lang.debug.external_logs }}
  • {{ lang.debug.static_logs }}
  • @@ -625,6 +626,29 @@ +
    +
    {{ lang.debug.log_info|format(log_lines+1)|raw }}
    +
    +
    + Crontasks +
    + +
    +
    + +
    +
    +