Skip to main content

Overview

The ExecutionLogger 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
Location: core/jobs/logger.go:569
You typically don’t need to call this directly. The JobManager creates ExecutionLogger instances automatically.

Logging Methods

Info

Logs an informational message. Location: core/jobs/logger.go:580 Example:

Error

Logs an error message (does not fail the job). Location: core/jobs/logger.go:581 Example:

Debug

Logs a debug message. Location: core/jobs/logger.go:582 Example:

Warn

Logs a warning message. Location: core/jobs/logger.go:583 Example:

Specialized Methods

Start

Logs the job start message with rocket emoji.
string
required
Human-readable job name
Location: core/jobs/logger.go:591 Example:

Success

Logs a success message with checkmark emoji. Location: core/jobs/logger.go:585 Example:

Progress

Logs a progress update with spinner emoji. Location: core/jobs/logger.go:588 Example:

Complete

Logs job completion with duration and checkmark emoji.
string
required
Completion message
Location: core/jobs/logger.go:594 Example:

Fail

Marks the job as failed with cross emoji. Sets job status to β€œfailed”.
error
required
Error that caused the failure
Location: core/jobs/logger.go:597 Example:

Statistics

Logs job statistics with chart emoji.
map[string]interface{}
required
Statistics to log (key-value pairs)
Location: core/jobs/logger.go:600 Example:

Utility Methods

GetOutput

Returns the complete buffered output (thread-safe). Location: core/jobs/logger.go:607

GetDuration

Returns the elapsed time since job start. Location: core/jobs/logger.go:613

WithContext

Creates a contextual logger with additional key-value pair in job ID.
string
required
Context key
string
required
Context value
Location: core/jobs/logger.go:617 Example:

Complete Examples

Basic Job Structure

Error Handling

Progress Tracking

Contextual Logging

Retry Logic

Log Output Format

Example:

Emoji Reference

Emojis make logs more readable in the dashboard UI. They’re automatically included by the specialized methods.

Best Practices

  1. Always Start and Finish: Call Start() at the beginning and Complete() or Fail() at the end
  2. Use Appropriate Levels: Info for normal flow, Warn for issues, Error for failures
  3. Log Statistics: Always use Statistics() to report metrics
  4. Progress Updates: Use Progress() for long-running operations
  5. Context for Multi-Entity Jobs: Use WithContext() when processing multiple entities
  6. Structured Data: Include structured data in logs (IDs, counts, durations)
  7. Avoid Sensitive Data: Don’t log passwords, API keys, or personal information
  8. Concise Messages: Keep log messages short and actionable