Add simple logging
This commit is contained in:
parent
9538caf330
commit
3e1765e810
@ -39,6 +39,7 @@ toml = "0.8.1"
|
|||||||
tree-sitter = "0.20.10"
|
tree-sitter = "0.20.10"
|
||||||
egui_extras = "0.24.2"
|
egui_extras = "0.24.2"
|
||||||
enum-iterator = "1.4.1"
|
enum-iterator = "1.4.1"
|
||||||
|
env_logger = "0.10"
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
env_logger = "0.10"
|
env_logger = "0.10"
|
||||||
|
@ -196,6 +196,8 @@ impl Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn expect_syntax_node(source: &str, expected: &str, actual: Node) -> Result<()> {
|
pub fn expect_syntax_node(source: &str, expected: &str, actual: Node) -> Result<()> {
|
||||||
|
log::info!("Converting {} to abstract node", actual.kind());
|
||||||
|
|
||||||
if expected == actual.kind() {
|
if expected == actual.kind() {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else if actual.is_error() {
|
} else if actual.is_error() {
|
||||||
|
12
src/main.rs
12
src/main.rs
@ -46,6 +46,8 @@ pub enum CliCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
env_logger::init();
|
||||||
|
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
if args.path.is_none() && args.command.is_none() {
|
if args.path.is_none() && args.command.is_none() {
|
||||||
@ -152,7 +154,7 @@ impl ToolHint {
|
|||||||
impl Hinter for DustReadline {
|
impl Hinter for DustReadline {
|
||||||
type Hint = ToolHint;
|
type Hint = ToolHint;
|
||||||
|
|
||||||
fn hint(&self, line: &str, pos: usize, _ctx: &Context<'_>) -> Option<Self::Hint> {
|
fn hint(&self, line: &str, pos: usize, _ctx: &Context) -> Option<Self::Hint> {
|
||||||
if line.is_empty() || pos < line.len() {
|
if line.is_empty() || pos < line.len() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -168,7 +170,7 @@ impl Hinter for DustReadline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Highlighter for DustReadline {
|
impl Highlighter for DustReadline {
|
||||||
fn highlight_hint<'h>(&self, hint: &'h str) -> std::borrow::Cow<'h, str> {
|
fn highlight_hint<'h>(&self, hint: &'h str) -> Cow<'h, str> {
|
||||||
let highlighted = ansi_term::Colour::Red.paint(hint).to_string();
|
let highlighted = ansi_term::Colour::Red.paint(hint).to_string();
|
||||||
|
|
||||||
Cow::Owned(highlighted)
|
Cow::Owned(highlighted)
|
||||||
@ -179,7 +181,6 @@ fn run_cli_shell() {
|
|||||||
let context = Map::new();
|
let context = Map::new();
|
||||||
let mut interpreter = Interpreter::new(context);
|
let mut interpreter = Interpreter::new(context);
|
||||||
let mut rl: Editor<DustReadline, DefaultHistory> = Editor::new().unwrap();
|
let mut rl: Editor<DustReadline, DefaultHistory> = Editor::new().unwrap();
|
||||||
let mut input = String::new();
|
|
||||||
|
|
||||||
rl.set_helper(Some(DustReadline::new()));
|
rl.set_helper(Some(DustReadline::new()));
|
||||||
|
|
||||||
@ -191,10 +192,8 @@ fn run_cli_shell() {
|
|||||||
let readline = rl.readline("* ");
|
let readline = rl.readline("* ");
|
||||||
match readline {
|
match readline {
|
||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
let line = line.as_str();
|
let input = line.to_string();
|
||||||
|
|
||||||
input.push('\n');
|
|
||||||
input.push_str(line);
|
|
||||||
rl.add_history_entry(line).unwrap();
|
rl.add_history_entry(line).unwrap();
|
||||||
|
|
||||||
let eval_result = interpreter.run(&input);
|
let eval_result = interpreter.run(&input);
|
||||||
@ -202,7 +201,6 @@ fn run_cli_shell() {
|
|||||||
match eval_result {
|
match eval_result {
|
||||||
Ok(value) => println!("{value}"),
|
Ok(value) => println!("{value}"),
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
input = input.trim_end_matches(line).to_string();
|
|
||||||
eprintln!("{error}")
|
eprintln!("{error}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,8 @@ impl Map {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set(&self, key: String, value: Value) -> Result<Option<(Value, Type)>> {
|
pub fn set(&self, key: String, value: Value) -> Result<Option<(Value, Type)>> {
|
||||||
|
log::info!("Setting variable {key} = {value}");
|
||||||
|
|
||||||
let value_type = value.r#type();
|
let value_type = value.r#type();
|
||||||
let previous = self
|
let previous = self
|
||||||
.variables
|
.variables
|
||||||
|
Loading…
Reference in New Issue
Block a user