I am trying to use LogglyLogger-CocoaLumberjack in my swift project.
I am getting this error in xCode.
Enum case 'verbose' has no associated values
I am unable to resolve this.
I am actually trying to translate the Objective-C code in swift 5. Here is my swift function
in appDelegate.swift class
func initLoggly(){
// static const DDLogLevel ddLogLevel = DDLogLevelVerbose;
let ddLogLevel:DDLogLevel = .verbose
// LogglyLogger *logglyLogger = [[LogglyLogger alloc] init];
let logglyLogger = LogglyLogger()
// [logglyLogger setLogFormatter:[[LogglyFormatter alloc] init]];
logglyLogger.logFormatter = LogglyFormatter()
// logglyLogger.logglyKey = @"your-loggly-api-key";
logglyLogger.logglyKey = "XXXXXXXXXXXX-XXXXXX"
//
// // Set posting interval every 15 seconds, just for testing this out, but the default value of 600 seconds is better in apps
// // that normally don't access the network very often. When the user suspends the app, the logs will always be posted.
// logglyLogger.saveInterval = 15;
logglyLogger.saveInterval = 15
// [DDLog addLogger:logglyLogger];
DDLog.add(logglyLogger)
// // Do some logging
// DDLogVerbose(@"{\"myJsonKey\":\"some verbose json value\"}");
// ddLogLevel.verbose("{\"initloggly\":\"some verbose json value\"}") // also tried this, error ==> Enum case 'verbose' cannot be used as an instance member
DDLogLevel.verbose("{\"initloggly\":\"some verbose json value\"}") // Here is the error on this line
}
Please point out what I am doing wrong!
This library is heavly based on C preprocessor macros which aren't accessible from Swift.
You will probably need to write a small set of wrapper functions in Objective-C that use these macros and are in turn callable from Swift.
Here's an example of how this could look like:
LogglyWrapper.h:
and LogglyWrapper.m:
usage from Swift: