An open API service indexing awesome lists of open source software.

https://github.com/jonaslang1/swiftlogging

SwiftLogging is a simple logging utility written in Swift.
https://github.com/jonaslang1/swiftlogging

logging swift swift-package-manager swift5

Last synced: 9 months ago
JSON representation

SwiftLogging is a simple logging utility written in Swift.

Awesome Lists containing this project

README

          

# SwiftLogging

SwiftLogging is a simple logging utility written in Swift. It provides a `Logger` class for handling different levels of log messages and a `LogFileManager` class for managing log files.

## Features

- Log messages at different levels: info, warning, error.
- Include file, function, and line number in log messages.
- Create and manage log files.

## Installation

Simply add the `Logger.swift` and `LogFileManager.swift` files to your project.

## Usage

### Logging Messages

```swift
let logger = Logger()

logger.info("This is an informational message")
logger.warning("This is a warning message")
logger.error("This is an error message")
```

### Managing Log Files
```swift
// Create a log file
LogFileManager.createLogFile()

// Get a list of log files
if let logFiles = LogFileManager.getLogFiles() {
for fileURL in logFiles {
print("Log file: \(fileURL.lastPathComponent)")
}
}

// Read the contents of a log file
if let firstLogFile = LogFileManager.getLogFiles()?.first,
let logContent = LogFileManager.readLogFile(atPath: firstLogFile) {
print("Log content:")
print(logContent)
}
```
## Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvement, feel free to open an issue or submit a pull request.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.