mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 21:54:47 +08:00
Move and rename files. NOAUTOREVERT=true NOPRESUBMIT=true NOTREECHECKS=true Bug: 768828 TBR=darin@chromium.org NOTRY=true Change-Id: I66d3b155808bc5bdbf237b80208e1e552bcf7f28 Reviewed-on: https://chromium-review.googlesource.com/1001153 Reviewed-by: Blink Reformat <blink-reformat@chromium.org> Commit-Queue: Blink Reformat <blink-reformat@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#549061} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 0aee4434a4dba42a42abaea9bfbc0cd196a63bc1
99 lines
2.0 KiB
JavaScript
99 lines
2.0 KiB
JavaScript
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
/**
|
|
* @unrestricted
|
|
*/
|
|
Common.Console = class extends Common.Object {
|
|
constructor() {
|
|
super();
|
|
/** @type {!Array.<!Common.Console.Message>} */
|
|
this._messages = [];
|
|
}
|
|
|
|
/**
|
|
* @param {string} text
|
|
* @param {!Common.Console.MessageLevel} level
|
|
* @param {boolean=} show
|
|
*/
|
|
addMessage(text, level, show) {
|
|
const message =
|
|
new Common.Console.Message(text, level || Common.Console.MessageLevel.Info, Date.now(), show || false);
|
|
this._messages.push(message);
|
|
this.dispatchEventToListeners(Common.Console.Events.MessageAdded, message);
|
|
}
|
|
|
|
/**
|
|
* @param {string} text
|
|
*/
|
|
log(text) {
|
|
this.addMessage(text, Common.Console.MessageLevel.Info);
|
|
}
|
|
|
|
/**
|
|
* @param {string} text
|
|
*/
|
|
warn(text) {
|
|
this.addMessage(text, Common.Console.MessageLevel.Warning);
|
|
}
|
|
|
|
/**
|
|
* @param {string} text
|
|
*/
|
|
error(text) {
|
|
this.addMessage(text, Common.Console.MessageLevel.Error, true);
|
|
}
|
|
|
|
/**
|
|
* @return {!Array.<!Common.Console.Message>}
|
|
*/
|
|
messages() {
|
|
return this._messages;
|
|
}
|
|
|
|
show() {
|
|
this.showPromise();
|
|
}
|
|
|
|
/**
|
|
* @return {!Promise.<undefined>}
|
|
*/
|
|
showPromise() {
|
|
return Common.Revealer.reveal(this);
|
|
}
|
|
};
|
|
|
|
/** @enum {symbol} */
|
|
Common.Console.Events = {
|
|
MessageAdded: Symbol('messageAdded')
|
|
};
|
|
|
|
/**
|
|
* @enum {string}
|
|
*/
|
|
Common.Console.MessageLevel = {
|
|
Info: 'info',
|
|
Warning: 'warning',
|
|
Error: 'error'
|
|
};
|
|
|
|
/**
|
|
* @unrestricted
|
|
*/
|
|
Common.Console.Message = class {
|
|
/**
|
|
* @param {string} text
|
|
* @param {!Common.Console.MessageLevel} level
|
|
* @param {number} timestamp
|
|
* @param {boolean} show
|
|
*/
|
|
constructor(text, level, timestamp, show) {
|
|
this.text = text;
|
|
this.level = level;
|
|
this.timestamp = (typeof timestamp === 'number') ? timestamp : Date.now();
|
|
this.show = show;
|
|
}
|
|
};
|
|
|
|
Common.console = new Common.Console();
|