Skip to content

Commit

Permalink
Fix log timezone in task log view (apache#19342)
Browse files Browse the repository at this point in the history
  • Loading branch information
calfzhou committed Nov 5, 2021
1 parent 5a113f3 commit b31bb40
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions airflow/www/static/js/ti_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

/* global document, window, $, */
/* global document, window, $, moment, Airflow */
import { escapeHtml } from './main';
import getMetaValue from './meta_value';
import { formatDateTime } from './datetime_utils';
Expand Down Expand Up @@ -115,9 +115,10 @@ function autoTailingLog(tryNumber, metadata = null, autoTailing = false) {

// The message may contain HTML, so either have to escape it or write it as text.
const escapedMessage = escapeHtml(item[1]);
const tzOffset = moment().tz(Airflow.serverTimezone).format('Z');
const linkifiedMessage = escapedMessage
.replace(urlRegex, (url) => `<a href="${url}" target="_blank">${url}</a>`)
.replaceAll(dateRegex, (date) => `<time datetime="${date}+00:00">${formatDateTime(`${date}+00:00`)}</time>`);
.replaceAll(dateRegex, (date) => `<time datetime="${date}${tzOffset}">${formatDateTime(`${date}${tzOffset}`)}</time>`);
logBlock.innerHTML += `${linkifiedMessage}\n`;
});

Expand Down

0 comments on commit b31bb40

Please sign in to comment.