The Decorator in AWK
Layer text transformations chronologically to augment the output string.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Transmutation // Layering
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
# The base text entity
function base_text() { return "System failure detected" }
# Decorator 1: Timestamp
function decor_timestamp(text) {
# In modern awk, systime() can be used
return "[2026-10-07 00:00:00] " text
}
# Decorator 2: Severity
function decor_severity(text, level) {
return text " (Severity: " level ")"
}
# Decorator 3: Colorization (ANSI Escape)
function decor_color_red(text) {
return "\033[31m" text "\033[0m"
}
BEGIN {
# Wrapping the entity in multiple layers of enchantment
final_msg = decor_color_red(decor_severity(decor_timestamp(base_text()), "CRITICAL"))
print final_msg
}
Functional composition acts as the Decorator in AWK. By passing the result of one function into another, we wrap the original string in layers of metadata, ANSI formatting, and contextual sigils without permanently modifying the core generation logic.
Runic Tags:
#awk
#text-processing
#structural