Overview
TheExecutionLogger provides structured logging methods for job executions. It captures all output to a buffer which is automatically saved to the _job_logs collection on job completion.
Type Definition
The ExecutionLogger is automatically created and passed to your job function by the JobManager. You donβt need to create it manually.
Constructor
NewExecutionLogger
string
required
Job identifier
string
required
Unique execution identifier
*Logger
required
Parent logger instance
core/jobs/logger.go:569
You typically donβt need to call this directly. The JobManager creates ExecutionLogger instances automatically.
Logging Methods
Info
core/jobs/logger.go:580
Example:
Error
core/jobs/logger.go:581
Example:
Debug
core/jobs/logger.go:582
Example:
Warn
core/jobs/logger.go:583
Example:
Specialized Methods
Start
string
required
Human-readable job name
core/jobs/logger.go:591
Example:
Success
core/jobs/logger.go:585
Example:
Progress
core/jobs/logger.go:588
Example:
Complete
string
required
Completion message
core/jobs/logger.go:594
Example:
Fail
error
required
Error that caused the failure
core/jobs/logger.go:597
Example:
Statistics
map[string]interface{}
required
Statistics to log (key-value pairs)
core/jobs/logger.go:600
Example:
Utility Methods
GetOutput
core/jobs/logger.go:607
GetDuration
core/jobs/logger.go:613
WithContext
string
required
Context key
string
required
Context value
core/jobs/logger.go:617
Example:
Complete Examples
Basic Job Structure
Error Handling
Progress Tracking
Contextual Logging
Retry Logic
Log Output Format
Emoji Reference
Emojis make logs more readable in the dashboard UI. Theyβre automatically included by the specialized methods.
Best Practices
- Always Start and Finish: Call
Start()at the beginning andComplete()orFail()at the end - Use Appropriate Levels: Info for normal flow, Warn for issues, Error for failures
- Log Statistics: Always use
Statistics()to report metrics - Progress Updates: Use
Progress()for long-running operations - Context for Multi-Entity Jobs: Use
WithContext()when processing multiple entities - Structured Data: Include structured data in logs (IDs, counts, durations)
- Avoid Sensitive Data: Donβt log passwords, API keys, or personal information
- Concise Messages: Keep log messages short and actionable
Related
- JobManager - Job registration and execution
- Logger - Underlying log storage system
- Job Dashboard - Viewing job logs in the UI