β οΈ IMPORTANT: π§ This package is still in development. π§ Please take that into consideration. π It should NOT be used in production! π
Echo is a flexible and easy-to-use logging framework for Swift applications. It is made with internal testers in mind. It provides a robust solution for capturing, storing, and analyzing log data in iOS applications in order to simplify exchanges between devs and internal testers.
- Features
- Requirements
- Installation
- Usage
- Configuration Options
- SwiftUI Integration
- UIKit Integration
- Built-in Log Viewer
- Visualizing and Exporting Logs
- License
- Multiple log levels (Debug, Info, Warning, Error, Critical)
- Customizable log categories
- In-memory and persistent storage of logs
- Log rotation and archiving
- Crash log capture
- Comprehensive log viewer with filtering and sorting capabilities
- SwiftUI and UIKit compatibility
- Thread-safe logging operations
- iOS 14.0+
- Swift 5.10+
Add the following dependency to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/thepearl/Echo.git", from: "1.0.0")
]
import Echo
let logger = Echo.Logger()
logger.log(.info, category: .network, message: "API request started")
logger.log(.error, category: .database, message: "Failed to save data")
let config = Echo.LoggerConfiguration(
minimumLogLevel: .debug,
maxLogEntries: 5000,
logRotationInterval: 86400 // 24 hours
)
let logger = Echo.Logger(configuration: config)
The following table explains the available configuration options for Echo:
Option | Type | Default | Description | Progress |
---|---|---|---|---|
minimumLogLevel | LogLevel | .debug | The minimum severity level of logs to be captured. Logs below this level will be ignored. | β |
maxLogEntries | Int | 10000 | The maximum number of log entries to keep in memory and storage. | β |
logRotationInterval | TimeInterval | 86400 (24 hours) | The time interval in seconds after which logs are rotated (archived and cleared). | β |
activeTimeRange | ClosedRange? | nil | An optional time range during which logging is active. If nil, logging is always active. | β |
persistenceStrategy | PersistenceStrategy | .fileSystem | Defines how logs are persisted. Options include .fileSystem, .coreData, or .inMemory. | π§ |
encryptionKey | String? | nil | An optional encryption key for securing stored logs. If provided, logs will be encrypted at rest. | π§ |
compressionEnabled | Bool | false | If true, logs will be compressed before storage to save space. | π§ |
networkLogOptions | NetworkLogOptions | .all | Configures what network-related information to log (e.g., headers, body, response). | π§ |
customFields | [String: Any] | [:] | Additional custom fields to include with each log entry. | π§ |
struct ContentView: View {
@StateObject private var logger = Echo.Logger()
var body: some View {
NavigationView {
Text("Hello, World!")
.logPageAppearance(pageName: "ContentView")
}
.environmentObject(logger)
}
}
class ViewController: UIViewController {
let logger = Echo.Logger()
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
logPageAppearance(logger: logger, pageName: "ViewController")
}
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
logPageDisappearance(logger: logger, pageName: "ViewController")
}
}
Echo provides a built-in log viewer for easy visualization and analysis of logs within your app:
struct LogViewerScreen: View {
@StateObject private var logger = Echo.Logger()
var body: some View {
LogViewer()
.environmentObject(logger)
}
}

The Log Viewer interface includes:
- A navigation bar with "Logs" as the title, and "Filter", sort, and share buttons.
- A search bar for filtering logs.
- A list of log entries, each showing:
- A brief description of the log message
- A category tag (e.g., "Database", "Business Logic", "Authentication")
- A severity level tag (e.g., "warning", "critical", "error", "debug", "info")
- A timestamp for each log entry
This interface allows for easy browsing, searching, and analysis of logs directly within your app.
Echo provides built-in capabilities for visualizing logs directly within your app and exporting them for further analysis by developers.
The LogViewer
component offers a comprehensive interface for viewing, filtering, and analyzing logs directly within your app. Key features include:
- Real-time log display
- Filtering by log level, category, and date range
- Full-text search across log messages
- Detailed view for individual log entries
Echo makes it easy to export logs for offline analysis or sharing with your development team:
let logger = Echo.Logger()
// Export logs as a formatted string
let exportedLogs = logger.exportLogs()
// Share logs using UIActivityViewController
let activityVC = UIActivityViewController(activityItems: [exportedLogs], applicationActivities: nil)
present(activityVC, animated: true)
Exported logs can be:
- Shared via email, messaging apps, or cloud storage
- Imported into analysis tools or spreadsheets
- Used for debugging sessions or bug reports
For more advanced visualization and analysis, there is work in progress to consider these approaches:
- Expand LogConfiguratons Add some more configurations (mentionned in the table) to make Echo even more flexible to work with.
- Custom Dashboards: Create custom SwiftUI views to visualize log data in charts or graphs that can be opened in mac-os.
- Integration with Analytics Tools: Export logs in a format compatible with popular analytics platforms.
- Automated Reports: Set up automated processes to generate daily or weekly log summaries for your development team.
By leveraging these visualization and export features, Echo will enable developers and testers to gain deeper insights into app behavior, streamline debugging processes, and facilitate effective communication within development teams.
Echo is available under the MIT license. See the LICENSE file for more info.