* @param {string} tag * @param {!LogLevel_Enum} level * @param {!Array} messages * @return {boolean} true if a the message was logged
(tag, level, messages)
| 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. |
no test coverage detected