UI Messaging

SolidGroundUX DocumentationSolidGroundUX
NL

Provide standardized console messaging helpers

Source: target-root/usr/local/lib/solidgroundux/common/ui-say.sh

Provide standardized console messaging helpers

Public functions

Internal functions
FunctionPurposeArgumentsOutput
_sgnd_lib_guardEnsure direct execution is rejected and record that the library has been sourced.——
_say_normalize_log_levelConvert aliases and legacy log-level names into a canonical—Writes the normalized log-level name to stdout.
_say_should_print_consoleDetermine whether a message of the specified type should be——
_say_should_write_logApply the file log level independently from console visibility.- $1 — TYPE - Message type.—
_say_callerFind the first non-say caller in the current Bash function stack.- No — arguments; reads FUNCNAME, BASH_SOURCE and BASH_LINENO.Prints caller function, file and line separated by tabs.
_say_write_logAppend an eligible structured message to the configured logfile.- $1 — message type; $2: text; $3: timestamp.Writes to the chosen logfile when the log level permits.
_sgnd_rotate_logsRotate a logfile when it reaches the configured size threshold.- $1 — logfile path; reads SGND_LOG_MAX_BYTES and SGND_LOG_KEEP.Moves old logfiles to rotated suffixes, optionally compressing them.
_sgnd_logfileSelect the first configured logfile that can be appended to.- No — arguments; reads SGND_LOG_PATH and SGND_ALTLOG_PATH.Prints the selected logfile path without a newline.
_sayprogress_write_slotUpdate one line of the multi-slot terminal progress display.- $1 — zero-based progress slot; $2: rendered text.Writes cursor positioning and text to stderr.
_sgnd_ensure_linebreakFinish a pending terminal output line before printing another message.- No — arguments; reads and clears SGND_LINEBREAK_PENDING.Prints a newline on stderr only when a line break is pending.

Description

Implements consistent message output helpers for console applications.

The library:

  • Provides a unified message API via say and typed wrappers (info, ok, warn, etc.)
  • Applies consistent formatting, prefixes, and optional colorization
  • Supports console output control via verbosity, debug flags, and message-type filtering
  • Ensures all messages follow a unified visual and structural style
  • Optionally performs best-effort file logging when enabled

Design principles

  • Consistent message semantics across all scripts
  • Separation of message intent (type) from rendering and output policy
  • Respect the framework log-level policy consistently
  • Keep output predictable and script-friendly

Role in framework

  • Core messaging layer used by all SolidGroundUX scripts
  • Serves as the primary mechanism for user-facing output and diagnostics
  • Works alongside ui.sh for rendering and formatting

Non-goals

  • Persistent logging frameworks or advanced log management
  • Complex formatting beyond message-level styling
  • Replacement for dedicated logging systems

Notes:

  • Console output is governed by SGND_CONSOLE_LOG_LEVEL; file output is governed by SGND_FILE_LOG_LEVEL.
  • File logging is optional and best-effort; failures do not affect execution.
  • Logfile writing is independent from console visibility.

Global defaults

Can be overridden in:

  • environment
  • styles/*.sh