Skip to main content

Logger

Struct Logger 

Source
pub struct Logger { /* private fields */ }
Expand description

Logger for Ralph output.

Provides consistent, colorized output with optional file logging. All messages include timestamps and appropriate icons.

Implementations§

Source§

impl Logger

Source

pub const fn new(colors: Colors) -> Self

Create a new Logger with the given colors configuration.

Source

pub fn with_log_file(self, path: &str) -> Self

Configure the logger to also write to a file using direct filesystem access.

Log messages written to the file will have ANSI codes stripped.

§Note

For pipeline code where a workspace exists, prefer [with_workspace_log] instead. This method uses std::fs directly and is intended for CLI layer code or legacy compatibility.

Source

pub fn with_workspace_log( self, workspace: Arc<dyn Workspace>, relative_path: &str, ) -> Self

Configure the logger to write logs via a workspace.

This is the preferred method for pipeline code where a workspace exists. Log messages will be written using the workspace abstraction, allowing for testing with MemoryWorkspace.

§Arguments
  • workspace - The workspace to use for file operations
  • relative_path - Path relative to workspace root for the log file
Source

pub fn info(&self, msg: &str)

Log an informational message.

Source

pub fn success(&self, msg: &str)

Log a success message.

Source

pub fn warn(&self, msg: &str)

Log a warning message.

Source

pub fn error(&self, msg: &str)

Log an error message.

Source

pub fn step(&self, msg: &str)

Log a step/action message.

Source

pub fn header(&self, title: &str, color_fn: fn(Colors) -> &'static str)

Print a section header with box drawing.

§Arguments
  • title - The header title text
  • color_fn - Function that returns the color to use
Source

pub fn subheader(&self, title: &str)

Print a sub-header (less prominent than header).

Trait Implementations§

Source§

impl Default for Logger

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Loggable for Logger

Source§

fn log(&self, msg: &str)

Write a log message to the sink. Read more
Source§

fn info(&self, msg: &str)

Log an informational message. Read more
Source§

fn success(&self, msg: &str)

Log a success message. Read more
Source§

fn warn(&self, msg: &str)

Log a warning message. Read more
Source§

fn error(&self, msg: &str)

Log an error message. Read more
Source§

fn header(&self, title: &str, color_fn: fn(Colors) -> &'static str)

Print a section header with box drawing. Read more
Source§

impl Printable for Logger

Source§

fn is_terminal(&self) -> bool

Check if this printer is connected to a terminal. Read more
Source§

impl Write for Logger

Source§

fn write(&mut self, buf: &[u8]) -> Result<usize>

Writes a buffer into this writer, returning how many bytes were written. Read more
Source§

fn flush(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · Source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

Like write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>

Attempts to write an entire buffer into this writer. Read more
Source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations§

§

impl Freeze for Logger

§

impl !RefUnwindSafe for Logger

§

impl Send for Logger

§

impl Sync for Logger

§

impl Unpin for Logger

§

impl !UnwindSafe for Logger

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.