1

I am creating a framework and stuck while making a wrapper for the class

logger.h which has below method

-(void) logError:(nonnull NSString *) info, ...;

I made a wrapper of logger.h file name Mlogger.h

The wrapper file Mlogger.h is having same prototype

-(void) logError:(nonnull NSString *) info, ...;

My Mlogger.m file implementation is as,

-(void) logError:(nonnull NSString *) info, ... {
    va_list args;
    va_start(args, info);
    [[Logger sharedManager] logError:info];
      //LogError(info,args); //also tried with macro
    va_end(args);
}

macro is define in logger.h :

#define LogError(format, ...) [[Logger sharedManager] logError:format , ##__VA_ARGS__ ];

I have imported wrapper class Mlogger.h and perform a call like,

[logger logDebug:@"Initialized successfully"];
[logger logDebug:@"URL: %@",@"www.google.com"];

The first line print perfectly but the second line prints URL : Logger: 0x604000226cc0..

expected output is URL: www.google.com

Is my implementation is correct? and not then how can i pass value of variadic parameters?

utkal patel
  • 1,321
  • 1
  • 15
  • 24

0 Answers0