MCPcopy
hub / github.com/ampproject/amphtml / msg_

Method msg_

src/utils/log.js:210–235  ·  view source on GitHub ↗

* @param {string} tag * @param {!LogLevel_Enum} level * @param {!Array} messages * @return {boolean} true if a the message was logged

(tag, level, messages)

Source from the content-addressed store, hash-verified

208 * @return {boolean} true if a the message was logged
209 */
210 msg_(tag, level, messages) {
211 if (level > (levelOverride_ ?? this.level_)) {
212 return false;
213 }
214
215 const cs = this.win.console;
216 const fn =
217 {
218 [LogLevel_Enum.ERROR]: cs.error,
219 [LogLevel_Enum.INFO]: cs.info,
220 [LogLevel_Enum.WARN]: cs.warn,
221 }[level] ?? cs.log;
222
223 const args = this.maybeExpandMessageArgs_(messages);
224 // Prefix console message with "[tag]".
225 const prefix = `[${tag}]`;
226 if (isString(args[0])) {
227 // Prepend string to avoid breaking string substitutions e.g. %s.
228 args[0] = prefix + ' ' + args[0];
229 } else {
230 args.unshift(prefix);
231 }
232 fn.apply(cs, args);
233
234 return true;
235 }
236
237 /**
238 * Reports a fine-grained message.

Callers 5

fineMethod · 0.95
infoMethod · 0.95
warnMethod · 0.95
errorMethod · 0.95
expectedErrorMethod · 0.95

Calls 3

isStringFunction · 0.90
applyMethod · 0.80

Tested by

no test coverage detected