diff --git a/Cargo.lock b/Cargo.lock index a2453031e..549eae40b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1992,11 +1992,13 @@ dependencies = [ name = "r3bl_rs_utils_core" version = "0.9.16" dependencies = [ + "assert_cmd", "chrono", "colorgrad", "crossterm 0.28.1", "futures-util", "log", + "miette", "nom", "pretty_assertions", "r3bl_ansi_color", @@ -2008,6 +2010,8 @@ dependencies = [ "sha2", "size-of", "strip-ansi", + "tempfile", + "thiserror", "time", "tokio", "tracing", @@ -2044,7 +2048,6 @@ dependencies = [ name = "r3bl_terminal_async" version = "0.5.7" dependencies = [ - "assert_cmd", "async-stream", "crossterm 0.28.1", "futures-core", @@ -2061,7 +2064,6 @@ dependencies = [ "r3bl_tuify", "strum", "strum_macros", - "tempfile", "thiserror", "tokio", "tracing", diff --git a/core/Cargo.toml b/core/Cargo.toml index b95165ade..b665b49d4 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -70,7 +70,21 @@ futures-util = "0.3.30" # Needed for cro # Color gradients. colorgrad = "0.7.0" +# Error handling. +thiserror = "1.0.63" +miette = { version = "7.2.0", features = ["fancy"] } +pretty_assertions = "1.4.0" + [dev-dependencies] # for assert_eq! macro pretty_assertions = "1.4.0" -serial_test = "3.1.1" \ No newline at end of file +serial_test = "3.1.1" + +# Testing - temp files and folders. +tempfile = "3.12.0" + +# Bin targets for testing stdout and stderr. +assert_cmd = "2.0.16" +[[bin]] +name = "tracing_test_bin" +path = "src/bin/tracing_test_bin.rs" diff --git a/terminal_async/src/bin/tracing_test_bin.rs b/core/src/bin/tracing_test_bin.rs similarity index 94% rename from terminal_async/src/bin/tracing_test_bin.rs rename to core/src/bin/tracing_test_bin.rs index 34c5c0966..07f49f05b 100644 --- a/terminal_async/src/bin/tracing_test_bin.rs +++ b/core/src/bin/tracing_test_bin.rs @@ -15,7 +15,7 @@ * limitations under the License. */ -use r3bl_terminal_async::{init_tracing, DisplayPreference, TracingConfig, WriterConfig}; +use r3bl_rs_utils_core::{init_tracing, DisplayPreference, TracingConfig, WriterConfig}; /// `assert_cmd` : /// diff --git a/core/src/lib.rs b/core/src/lib.rs index 7ae21ed58..599a7877d 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -132,6 +132,7 @@ pub mod decl_macros; pub mod logging; pub mod misc; pub mod terminal_io; +pub mod tracing_logging; pub mod tui_core; // Re-export. @@ -140,4 +141,5 @@ pub use decl_macros::*; pub use logging::*; pub use misc::*; pub use terminal_io::*; +pub use tracing_logging::*; pub use tui_core::*; diff --git a/terminal_async/src/tracing_logging/init_tracing.rs b/core/src/tracing_logging/init_tracing.rs similarity index 94% rename from terminal_async/src/tracing_logging/init_tracing.rs rename to core/src/tracing_logging/init_tracing.rs index 2723c1ff7..554036af0 100644 --- a/terminal_async/src/tracing_logging/init_tracing.rs +++ b/core/src/tracing_logging/init_tracing.rs @@ -15,6 +15,16 @@ * limitations under the License. */ +//! # [init_tracing] +//! +//! This is a convenience method to setup Tokio [`tracing_subscriber`] with `stdout` as +//! the output destination. This method also ensures that the [`crate::SharedWriter`] is +//! used for concurrent writes to `stdout`. You can also use the [`TracingConfig`] struct +//! to customize the behavior of the tracing setup, by choosing whether to display output +//! to `stdout`, `stderr`, or a [`crate::SharedWriter`]. By default, both display and file +//! logging are enabled. You can also customize the log level, and the file path and +//! prefix for the log file. + use tracing_core::LevelFilter; use tracing_subscriber::{layer::SubscriberExt, registry::LookupSpan, @@ -258,9 +268,8 @@ mod test_tracing_bin_stdio { #[cfg(test)] mod test_tracing_shared_writer_output { - use r3bl_rs_utils_core::{LineStateControlSignal, SharedWriter}; - use super::*; + use crate::{LineStateControlSignal, SharedWriter}; const EXPECTED: [&str; 4] = ["error", "warn", "info", "debug"]; diff --git a/terminal_async/src/tracing_logging/mod.rs b/core/src/tracing_logging/mod.rs similarity index 100% rename from terminal_async/src/tracing_logging/mod.rs rename to core/src/tracing_logging/mod.rs diff --git a/terminal_async/src/tracing_logging/rolling_file_appender_impl.rs b/core/src/tracing_logging/rolling_file_appender_impl.rs similarity index 100% rename from terminal_async/src/tracing_logging/rolling_file_appender_impl.rs rename to core/src/tracing_logging/rolling_file_appender_impl.rs diff --git a/terminal_async/src/tracing_logging/tracing_config.rs b/core/src/tracing_logging/tracing_config.rs similarity index 98% rename from terminal_async/src/tracing_logging/tracing_config.rs rename to core/src/tracing_logging/tracing_config.rs index a3840f100..07075cc8c 100644 --- a/terminal_async/src/tracing_logging/tracing_config.rs +++ b/core/src/tracing_logging/tracing_config.rs @@ -17,9 +17,10 @@ use std::fmt::Debug; -use r3bl_rs_utils_core::SharedWriter; use tracing_core::LevelFilter; +use crate::SharedWriter; + /// Configure the tracing logging to suit your needs. You can display the logs to a: /// 1. file, /// 2. stdout, stderr, or a shared writer, diff --git a/terminal_async/Cargo.toml b/terminal_async/Cargo.toml index 44b80134f..4c48ba3a8 100644 --- a/terminal_async/Cargo.toml +++ b/terminal_async/Cargo.toml @@ -78,15 +78,6 @@ async-stream = "0.3.5" # Testing - r3bl-open-core. r3bl_test_fixtures = { path = "../test_fixtures" } -# Testing - temp files and folders. -tempfile = "3.12.0" - -# Bin targets for testing stdout and stderr. -assert_cmd = "2.0.16" -[[bin]] -name = "tracing_test_bin" -path = "src/bin/tracing_test_bin.rs" - [features] default = ["emacs"] emacs = [] diff --git a/terminal_async/README.md b/terminal_async/README.md index 78eef9078..18897335d 100644 --- a/terminal_async/README.md +++ b/terminal_async/README.md @@ -103,7 +103,6 @@ niceties & ergonomics that all Rustaceans 🦀 can enjoy 🎉. - [Readline overview please see the docs for this struct for details](#readline-overview-please-see-the-docs-for-this-struct-for-details) - [Spinner::try_start](#spinnertry_start) - - [init_tracing()](#init_tracing) - [Build this crate with Naz on YouTube](#build-this-crate-with-naz-on-youtube) - [Why another async readline crate?](#why-another-async-readline-crate) - [References for blocking and thread cancellation in @@ -365,17 +364,6 @@ have ANSI escape sequences in them. Here's an example of this. Ok(()) ``` -### [`init_tracing()`] - -This is a convenience method to setup Tokio [`tracing_subscriber`] with `stdout` as -the output destination. This method also ensures that the -[`r3bl_rs_utils_core::SharedWriter`] is used for concurrent writes to `stdout`. You -can also use the [`TracingConfig`] struct to customize the behavior of the tracing -setup, by choosing whether to display output to `stdout`, `stderr`, or a -[`r3bl_rs_utils_core::SharedWriter`]. By default, both display and file logging are -enabled. You can also customize the log level, and the file path and prefix for the -log file. - ## Build this crate with Naz on YouTube Watch the following videos to learn more about how this crate was built: diff --git a/terminal_async/examples/terminal_async.rs b/terminal_async/examples/terminal_async.rs index a512976de..677b14288 100644 --- a/terminal_async/examples/terminal_async.rs +++ b/terminal_async/examples/terminal_async.rs @@ -22,10 +22,10 @@ use std::{io::{stderr, Write}, use crossterm::style::Stylize; use miette::IntoDiagnostic; -use r3bl_rs_utils_core::SharedWriter; -use r3bl_terminal_async::{tracing_logging::tracing_config::TracingConfig, - DisplayPreference, - Readline, +use r3bl_rs_utils_core::{tracing_logging::tracing_config::TracingConfig, + DisplayPreference, + SharedWriter}; +use r3bl_terminal_async::{Readline, ReadlineEvent, Spinner, SpinnerStyle, @@ -152,7 +152,7 @@ async fn main() -> miette::Result<()> { } // Initialize tracing w/ the "async stdout" (SharedWriter), and file writer. - r3bl_terminal_async::init_tracing(TracingConfig::new_file_and_display( + r3bl_rs_utils_core::init_tracing(TracingConfig::new_file_and_display( None, DisplayPreference::SharedWriter(terminal_async.clone_shared_writer()), ))?; diff --git a/terminal_async/src/lib.rs b/terminal_async/src/lib.rs index c54fc0bca..6276082ec 100644 --- a/terminal_async/src/lib.rs +++ b/terminal_async/src/lib.rs @@ -118,7 +118,6 @@ //! - [Readline overview please see the docs for this struct for //! details](#readline-overview-please-see-the-docs-for-this-struct-for-details) //! - [Spinner::try_start](#spinnertry_start) -//! - [init_tracing()](#init_tracing) //! - [Build this crate with Naz on YouTube](#build-this-crate-with-naz-on-youtube) //! - [Why another async readline crate?](#why-another-async-readline-crate) //! - [References for blocking and thread cancellation in @@ -384,17 +383,6 @@ //! # } //! ``` //! -//! ## [`init_tracing()`] -//! -//! This is a convenience method to setup Tokio [`tracing_subscriber`] with `stdout` as -//! the output destination. This method also ensures that the -//! [`r3bl_rs_utils_core::SharedWriter`] is used for concurrent writes to `stdout`. You -//! can also use the [`TracingConfig`] struct to customize the behavior of the tracing -//! setup, by choosing whether to display output to `stdout`, `stderr`, or a -//! [`r3bl_rs_utils_core::SharedWriter`]. By default, both display and file logging are -//! enabled. You can also customize the log level, and the file path and prefix for the -//! log file. -//! //! # Build this crate with Naz on YouTube //! //! Watch the following videos to learn more about how this crate was built: @@ -471,14 +459,12 @@ pub mod public_api; pub mod readline_impl; pub mod spinner_impl; pub mod tracing_jaeger; -pub mod tracing_logging; // Re-export the public API. pub use public_api::*; pub use readline_impl::*; pub use spinner_impl::*; pub use tracing_jaeger::*; -pub use tracing_logging::*; // External crates. use std::{collections::VecDeque, io::Error, pin::Pin, sync::Arc}; diff --git a/tui/README.md b/tui/README.md index 342541bd6..baa03583c 100644 --- a/tui/README.md +++ b/tui/README.md @@ -877,15 +877,15 @@ let st = lolcat_mut.colorize_to_styled_texts(&unicode_string); lolcat.next_color(); ``` -This [crate::Lolcat] that is returned by `build()` is safe to re-use. +This [r3bl_rs_utils_core::Lolcat] that is returned by `build()` is safe to re-use. - The colors it cycles through are "stable" meaning that once constructed via the - [builder](crate::LolcatBuilder) (which sets the speed, seed, and delta that - determine where the color wheel starts when it is used). For eg, when used in a + [builder](r3bl_rs_utils_core::LolcatBuilder) (which sets the speed, seed, and delta + that determine where the color wheel starts when it is used). For eg, when used in a dialog box component that re-uses the instance, repeated calls to the `render()` function of this component will produce the same generated colors over and over again. - If you want to change where the color wheel "begins", you have to change the speed, - seed, and delta of this [crate::Lolcat] instance. + seed, and delta of this [r3bl_rs_utils_core::Lolcat] instance. ## Issues and PRs diff --git a/tui/src/lib.rs b/tui/src/lib.rs index fe5d23474..63c5ebf3f 100644 --- a/tui/src/lib.rs +++ b/tui/src/lib.rs @@ -892,15 +892,15 @@ //! lolcat.next_color(); //! ``` //! -//! This [crate::Lolcat] that is returned by `build()` is safe to re-use. +//! This [r3bl_rs_utils_core::Lolcat] that is returned by `build()` is safe to re-use. //! - The colors it cycles through are "stable" meaning that once constructed via the -//! [builder](crate::LolcatBuilder) (which sets the speed, seed, and delta that -//! determine where the color wheel starts when it is used). For eg, when used in a +//! [builder](r3bl_rs_utils_core::LolcatBuilder) (which sets the speed, seed, and delta +//! that determine where the color wheel starts when it is used). For eg, when used in a //! dialog box component that re-uses the instance, repeated calls to the `render()` //! function of this component will produce the same generated colors over and over //! again. //! - If you want to change where the color wheel "begins", you have to change the speed, -//! seed, and delta of this [crate::Lolcat] instance. +//! seed, and delta of this [r3bl_rs_utils_core::Lolcat] instance. //! //! # Issues and PRs //! diff --git a/tui/src/tui/layout/props.rs b/tui/src/tui/layout/props.rs index beb222ab3..03230cdd1 100644 --- a/tui/src/tui/layout/props.rs +++ b/tui/src/tui/layout/props.rs @@ -19,7 +19,7 @@ use r3bl_rs_utils_core::{Position, RequestedSizePercent, Size, TuiStyle}; use super::{FlexBoxId, LayoutDirection}; -/// Properties that are needed to create a [FlexBox]. +/// Properties that are needed to create a [crate::FlexBox]. #[derive(Clone, Debug, Default)] pub struct FlexBoxProps { pub id: FlexBoxId, diff --git a/tui/src/tui/syntax_highlighting/md_parser_syn_hi/md_parser_syn_hi_impl.rs b/tui/src/tui/syntax_highlighting/md_parser_syn_hi/md_parser_syn_hi_impl.rs index f7dd3aeba..431289c05 100644 --- a/tui/src/tui/syntax_highlighting/md_parser_syn_hi/md_parser_syn_hi_impl.rs +++ b/tui/src/tui/syntax_highlighting/md_parser_syn_hi/md_parser_syn_hi_impl.rs @@ -78,10 +78,10 @@ use crate::{constants::{AUTHORS, StyleUSSpanLines, US}; -/// This is the main function that the [editor] uses this in order to display the markdown to the -/// user.It is responsible for converting: -/// - from a &[Vec] of [US] which comes from the [editor], -/// - into a [StyleUSSpanLines], which the [editor] will clip & render. +/// This is the main function that the [crate::editor] uses this in order to display the +/// markdown to the user.It is responsible for converting: +/// - from a &[Vec] of [US] which comes from the [crate::editor], +/// - into a [StyleUSSpanLines], which the [crate::editor] will clip & render. /// /// # Arguments /// - `editor_text` - The text that the user has typed into the editor. diff --git a/tui/src/tui/terminal_lib_backends/z_order.rs b/tui/src/tui/terminal_lib_backends/z_order.rs index e1fa0f6bf..287732cee 100644 --- a/tui/src/tui/terminal_lib_backends/z_order.rs +++ b/tui/src/tui/terminal_lib_backends/z_order.rs @@ -27,7 +27,8 @@ pub enum ZOrder { } impl ZOrder { - /// Contains the priority that is used to paint the different groups of [RenderOp] items. + /// Contains the priority that is used to paint the different groups of + /// [crate::RenderOp] items. pub fn get_render_order() -> [ZOrder; 3] { [ZOrder::Normal, ZOrder::High, ZOrder::Glass] }