I am using CocoaLumberjack for a Swift project. I would like to implement custom log levels/flags, as I would like to use 6 rather than the default 5, and would prefer different names.
The documentation for doing this is not helpful. It is only a solution for Objective-C.
The fact that DDLogFlag
is defined as NS_OPTIONS
means I actually could simply ignore the pre-defined values here, create my own constants, and just write some wrapping code to convert from one to the other.
However, DDLogLevel
is defined as NS_ENUM
, which means Swift won't be very happy with me trying to instantiate something to say 0b111111
, which isn't an existing value in the enum. If it were an NS_OPTIONS
, like DDLogFlag
, I could just ignore the pre-existing definitions from the library and use whatever valid UInt
values I wanted to.
As far as I can tell, I just have to write some Objective-C code to define my own replacements for DDLogLevel
, DDLogFlag
, and write a custom function to pass this in to and access these properties on DDLogMessage
. But this feels bad.
How can I use my own custom logging levels in Swift with CocoaLumberjack?