Skip to content

3. Custom Log Output Format Parsing

Damon东哥 edited this page Mar 20, 2025 · 1 revision

If you want to customize the log output content, you can conform the type to the LogContent protocol. For example, to print only the path of a URL type, simply define the logStringValue property as shown below:

extension URL: LogContent {
    public var logStringValue: String {
        return self.path
    }
}

By default, DDLoggerSwift converts Dictionary and Array types to JSON format. If you need to customize the output for other types, implement the LogContent protocol accordingly.

Clone this wiki locally