1/** 2 * Copyright © Magento, Inc. All rights reserved. 3 * See COPYING.txt for license details. 4 */ 5 6define([ 7 'moment', 8 'mage/utils/template' 9], function (moment, mageTemplate) { 10 'use strict'; 11 12 /** 13 * @param {String} dateFormat 14 * @param {String} template 15 */ 16 function LogFormatter(dateFormat, template) { 17 /** 18 * @protected 19 * @type {String} 20 */ 21 this.dateFormat_ = 'YYYY-MM-DD HH:mm:ssZ'; 22 23 /** 24 * @protected 25 * @type {String} 26 */ 27 this.template_ = '[${ $.date }] [${ $.entry.levelName }] ${ $.message }'; 28 29 if (dateFormat) { 30 this.dateFormat_ = dateFormat; 31 } 32 33 if (template) { 34 this.template_ = template; 35 } 36 } 37 38 /** 39 * @param {LogEntry} entry 40 * @returns {String} 41 */ 42 LogFormatter.prototype.process = function (entry) { 43 var message = mageTemplate.template(entry.message, entry.data), 44 date = moment(entry.timestamp).format(this.dateFormat_); 45 46 return mageTemplate.template(this.template_, { 47 date: date, 48 entry: entry, 49 message: message 50 }); 51 }; 52 53 return LogFormatter; 54});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.