mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
Support syntax highlighting of arguments in the devtools console (#34810)
* Implement Builder struct for console messages Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Support integer arguments for console methods Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Support floating point arguments to console methods in devtools Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Fix warnings Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Tidy Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
parent
7c023ee02a
commit
b252f238d1
4 changed files with 242 additions and 95 deletions
|
@ -17,7 +17,7 @@ use devtools_traits::EvaluateJSReply::{
|
|||
};
|
||||
use devtools_traits::{
|
||||
CachedConsoleMessage, CachedConsoleMessageTypes, ConsoleLog, ConsoleMessage,
|
||||
DevtoolScriptControlMsg, LogLevel, PageError,
|
||||
DevtoolScriptControlMsg, PageError,
|
||||
};
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use log::debug;
|
||||
|
@ -272,40 +272,17 @@ impl ConsoleActor {
|
|||
id: UniqueId,
|
||||
registry: &ActorRegistry,
|
||||
) {
|
||||
let level = match console_message.log_level {
|
||||
LogLevel::Debug => "debug",
|
||||
LogLevel::Info => "info",
|
||||
LogLevel::Warn => "warn",
|
||||
LogLevel::Error => "error",
|
||||
LogLevel::Clear => "clear",
|
||||
LogLevel::Trace => "trace",
|
||||
LogLevel::Log => "log",
|
||||
}
|
||||
.to_owned();
|
||||
|
||||
let console_api = ConsoleLog {
|
||||
level,
|
||||
filename: console_message.filename,
|
||||
line_number: console_message.line_number as u32,
|
||||
column_number: console_message.column_number as u32,
|
||||
time_stamp: SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_millis() as u64,
|
||||
arguments: vec![console_message.message],
|
||||
stacktrace: console_message.stacktrace,
|
||||
};
|
||||
|
||||
let log_message: ConsoleLog = console_message.into();
|
||||
self.cached_events
|
||||
.borrow_mut()
|
||||
.entry(id.clone())
|
||||
.or_default()
|
||||
.push(CachedConsoleMessage::ConsoleLog(console_api.clone()));
|
||||
.push(CachedConsoleMessage::ConsoleLog(log_message.clone()));
|
||||
if id == self.current_unique_id(registry) {
|
||||
if let Root::BrowsingContext(bc) = &self.root {
|
||||
registry
|
||||
.find::<BrowsingContextActor>(bc)
|
||||
.resource_available(console_api, "console-message".into())
|
||||
.resource_available(log_message, "console-message".into())
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue