diff --git a/src/error/syntax_error.rs b/src/error/syntax_error.rs index 0ff3689..b420b20 100644 --- a/src/error/syntax_error.rs +++ b/src/error/syntax_error.rs @@ -52,7 +52,7 @@ impl SyntaxError { } pub fn expect_syntax_node(expected: &str, actual: SyntaxNode) -> Result<(), SyntaxError> { - log::info!("Converting {} to abstract node", actual.kind()); + log::trace!("Converting {} to abstract node", actual.kind()); if expected == actual.kind() { Ok(()) diff --git a/src/interpret.rs b/src/interpret.rs index fbe957a..0829c61 100644 --- a/src/interpret.rs +++ b/src/interpret.rs @@ -88,7 +88,7 @@ impl Interpreter { .expect("Language version is incompatible with tree sitter version."); parser.set_logger(Some(Box::new(|_log_type, message| { - log::debug!("{}", message) + log::trace!("{}", message) }))); Interpreter { parser, context } diff --git a/src/main.rs b/src/main.rs index d1f216a..73b34d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ //! Command line interface for the dust programming language. use clap::{Parser, Subcommand}; +use colored::Colorize; use crossterm::event::{KeyCode, KeyModifiers}; use nu_ansi_term::{Color, Style}; use reedline::{ @@ -8,7 +9,7 @@ use reedline::{ Reedline, ReedlineEvent, ReedlineMenu, Signal, Span, SqliteBackedHistory, Suggestion, }; -use std::{borrow::Cow, fs::read_to_string, path::PathBuf, process::Command}; +use std::{borrow::Cow, fs::read_to_string, io::Write, path::PathBuf, process::Command}; use dust_lang::{ built_in_values::all_built_in_values, Context, ContextMode, Error, Interpreter, Value, @@ -41,7 +42,15 @@ pub enum CliCommand { } fn main() { - env_logger::init(); + env_logger::Builder::from_env("DUST_LOG") + .format(|buffer, record| { + let args = record.args(); + let log_level = record.level().to_string().bold(); + let timestamp = buffer.timestamp_seconds().to_string().dimmed(); + + writeln!(buffer, "[{log_level} {timestamp}] {args}") + }) + .init(); let args = Args::parse(); let context = Context::new(ContextMode::AllowGarbage);