Skip to main content

Console

The Console module provides comprehensive console output, logging, and formatting capabilities for Soul. It offers a JavaScript-style API for handling console operations including logging at different levels, reading user input, and managing console display.

Logging Methods

log - General purpose logging

Log messages to the console with automatic formatting:
Print messages without adding a newline character:

info - Information messages

Log informational messages:

warn - Warning messages

Log warning messages:

error - Error messages

Log error messages:

Input Operations

read - Read user input

Read a line of input from the user:

Display Management

clear - Clear console screen

Clear the console screen:

newLine - Print newline character

Print a newline character for spacing:

Practical Examples

Interactive Console Application

Progress Indicator

Logging System

Formatted Output

Error Handling with Console

Best Practices

  1. Use appropriate log levels: Choose the right logging method for your message type
  2. Clear console judiciously: Only clear when it improves user experience
  3. Format output clearly: Use spacing and separators for readability
  4. Handle input validation: Always validate user input from Console.read()
  5. Provide feedback: Keep users informed about what’s happening
The Console module provides essential tools for creating interactive command-line applications in Soul, with support for various logging levels, user input, and display management features that enable rich console experiences.