Disruptive Documentation Beta

Function DTLog(_:​level:​file​Path:​function​Name:​line​Number:​)

public func DTLog(_ message: Any = "", level: LogLevel = .info, filePath: String = #file, functionName: String = #function, lineNumber: Int = #line)

Provides a nicely formatted log output with the file, function, and line number the log statement came from. Also includes a timestamp with millisecond accuracy.

Here are some examples of the output format:

2021-01-11 02:01:28.084    l:122   Authentication.swift   getActiveAccessToken(comple...   Authentication successful
2021-01-11 02:04:32.512    l:94    main.swift             main()                           Fetched 28 devices
2021-01-11 02:04:31.506    l:108   main.swift             main()                           🐛 This is a debug log
2021-01-11 02:04:31.507    l:109   main.swift             main()                           ⚠️ This is a warning
2021-01-11 02:04:31.507    l:110   main.swift             main()                           ❌ This is an error

Parameters

message Any

The thing that should be log. This will be converted to a String like this: String(describing: message)

level Log​Level

The severity of the log. Will be used as a prefix before message. The default is .info (no prefix).

file​Path String

Should be left as-is to get the correct file path.

function​Name String

Should be left as-is to get the correct function name.

line​Number Int

Should be left as-is to get the correct line number.