Scrubbed extract of
Structured-Logging-Go/Epic-2-Stories/US-2.2-Emoji-Level-Mapping.md— cited by the Chronicle (02-first-instruments). Redactions: phone / service detail / secrets / clearance / personal / internal hosts.
type: story category: Work project: Structured-Logging-Go priority: High status: backlog created: 2026-03-23 epic: Epic-2-Domain-Extensions-Emoji user-story: US-2.2 effort: 4h precedence:
- “[[US-1.1-Module-Scaffolding-Logger-Options]]” parallel_group: Presentation tokens: 0 model: null tags:
- user-story
- epic-2
- emoji
US 2.2: Emoji Level Mapping
Epic: [[Epic-2-Stories/README|Epic 2: Domain Extensions & Emoji]]
Agent: Unassigned
Effort: 4 hours
Priority: 🔼 High
Status: 🔵 Backlog
User Story
As a developer reading console logs during local development
I want each log line prefixed with a level-appropriate emoji
So that I can instantly spot warnings and errors while scanning output
Acceptance Criteria
-
emoji.gocreated with level → emoji mapping function 🔼 - Level mapping: Debug→🔍 Info→ℹ️ Warn→⚠️ Error→❌ DPanic/Panic/Fatal→💥
-
EmojiForLevel(level zapcore.Level) stringexported function - Custom
zapcore.Encoderwrapper that prepends emoji to console output whenWithEmojiOutput(true)is set -
WithEmojiOutput(true)option inoptions.goactivates the emoji encoder - Emoji only added in console/dev output — JSON encoding is unaffected
- Optional
LevelEmojifield added to JSON output (opt-in viaWithEmojiField(true)) - Unit tests verify correct emoji for all zap levels
-
go test ./...passes
Definition of Done
- Emoji encoder wrapper compiles and works with zap’s console encoder
- All levels produce the correct emoji in unit tests
- JSON output unaffected unless
WithEmojiFieldis explicitly enabled
Technical Notes
func EmojiForLevel(level zapcore.Level) string {
switch level {
case zapcore.DebugLevel:
return "🔍"
case zapcore.InfoLevel:
return "ℹ️"
case zapcore.WarnLevel:
return "⚠️"
case zapcore.ErrorLevel:
return "❌"
case zapcore.DPanicLevel, zapcore.PanicLevel, zapcore.FatalLevel:
return "💥"
default:
return "ℹ️"
}
}
Encoder wrapper approach: Wrap zapcore.Encoder and override EncodeEntry to prepend the emoji to the log line. This avoids modifying the output template and works with any console encoder config.
Related Documentation
- [[US-1.1-Module-Scaffolding-Logger-Options]] —
WithEmojiOutputoption defined here - [[Projects/Structured-Logging/Epic-2-Stories/US-2.1-Emoji-Enricher|C# Reference: US 2.1]]
Agent Execution Log
Work Sessions
| Date | Agent | Model | Tokens | Action |
|---|---|---|---|---|
| — | — | — | 0 | Not started |