atomvm_gleam/console

Console output wrappers for AtomVM console.

Writes are not suffixed with a newline unless the caller includes one.

Upstream: console.erl · Docs: Module console

Types

Opaque handle for the AtomVM console port (console:start/0).

See Module console.

pub type Console

Errors from console operations.

pub type Error {
  Failed
  NotSupported
  Badarg
  Timeout
  Other(String)
}

Constructors

  • Failed
  • NotSupported
  • Badarg
  • Timeout
  • Other(String)

Values

pub fn error_to_string(error: Error) -> String

Format an Error for logging.

pub fn flush() -> Result(Nil, Error)

Flush previously written console data.

See console:flush/0.

pub fn flush_handle(console: Console) -> Result(Nil, Error)

Flush previously written data via an existing console port handle.

See console:flush/1.

pub fn print(text: String) -> Result(Nil, Error)

Write a string to the console (NIF path; no trailing newline unless present).

See console:print/1.

pub fn print_err(text: String) -> Result(Nil, Error)

Write a string to standard error (no trailing newline unless present in text).

Added in AtomVM 0.7 beta.

See console:print_err/1.

pub fn puts(text: String) -> Result(Nil, Error)

Write a string to the console (no trailing newline unless present in text).

See console:puts/1.

pub fn puts_to(
  console: Console,
  text: String,
) -> Result(Nil, Error)

Write a string via an existing console port handle.

See console:puts/2.

pub fn start() -> Result(Console, Error)

Ensure the console port is started and registered, returning its handle.

Usually unnecessary — puts / flush start it on demand — but useful for eager initialization or for puts_to / flush_handle.

See console:start/0.

✨ Search Document