//
//  XTLogger.h
//  TadsTerp
//
//  Created by Rune Berg on 14/04/14.
//  Copyright (c) 2014 Rune Berg. All rights reserved.
//

#import <Foundation/Foundation.h>


#define XT_DEF_SELNAME  NSString *selName = NSStringFromSelector(_cmd);
#define XT_SELNAME      selName
#define XT_TRACE_ENTRY  XT_DEF_SELNAME; [logger trace:@"%@", XT_SELNAME];
#define XT_TRACE_0(fmt) [logger trace:@"%@ " fmt, XT_SELNAME];
#define XT_TRACE_1(fmt,arg1) [logger trace:@"%@ " fmt, XT_SELNAME, arg1];
#define XT_TRACE_2(fmt,arg1,arg2) [logger trace:@"%@ " fmt, XT_SELNAME, arg1, arg2];
#define XT_TRACE_3(fmt,arg1,arg2,arg3) [logger trace:@"%@ " fmt, XT_SELNAME, arg1, arg2, arg3];
#define XT_TRACE_4(fmt,arg1,arg2,arg3,arg4) [logger trace:@"%@ " fmt, XT_SELNAME, arg1, arg2, arg3, arg4];
#define XT_TRACE_5(fmt,arg1,arg2,arg3,arg4,arg5) [logger trace:@"%@ " fmt, XT_SELNAME, arg1, arg2, arg3, arg4, arg5];
#define XT_TRACE_6(fmt,arg1,arg2,arg3,arg4,arg5,arg6) [logger trace:@"%@ " fmt, XT_SELNAME, arg1, arg2, arg3, arg4, arg5, arg6];
#define XT_WARN_0(fmt) [logger warn:@"%@ " fmt, XT_SELNAME];
#define XT_WARN_1(fmt,arg1) [logger warn:@"%@ " fmt, XT_SELNAME, arg1];
#define XT_WARN_2(fmt,arg1,arg2) [logger warn:@"%@ " fmt, XT_SELNAME, arg1, arg2];
#define XT_WARN_3(fmt,arg1,arg2,arg3) [logger warn:@"%@ " fmt, XT_SELNAME, arg1, arg2, arg3];
#define XT_WARN_4(fmt,arg1,arg2,arg3,arg4) [logger warn:@"%@ " fmt, XT_SELNAME, arg1, arg2, arg3, arg4];
#define XT_ERROR_0(fmt) [logger error:@"%@ " fmt, XT_SELNAME];
#define XT_ERROR_1(fmt,arg1) [logger error:@"%@ " fmt, XT_SELNAME, arg1];
#define XT_ERROR_2(fmt,arg1,arg2) [logger error:@"%@ " fmt, XT_SELNAME, arg1, arg2];
#define XT_ERROR_3(fmt,arg1,arg2,arg3) [logger error:@"%@ " fmt, XT_SELNAME, arg1, arg2, arg3];
#define XT_TRACE_ON (logger.level >= XT_LEVEL_TRACE)


@interface XTLogger : NSObject

typedef NS_ENUM(NSInteger, XTLoggerLevel) {
	XT_LEVEL_TRACE = 10,
	XT_LEVEL_DEBUG = 20,
	XT_LEVEL_INFO = 30,
	XT_LEVEL_WARN = 40,
	XT_LEVEL_ERROR = 50,
	XT_LEVEL_FATAL = 60,
	XT_LEVEL_OFF = 9999
};

@property NSString *name;
@property XTLoggerLevel level;

+ (instancetype)loggerForClass:(Class)aClass;

+ (instancetype)loggerNamed:(NSString *)name;

- (void)trace:(NSString *)format, ...;

- (void)debug:(NSString *)format, ...;

- (void)info:(NSString *)format, ...;

- (void)warn:(NSString *)format, ...;

- (void)error:(NSString *)format, ...;

- (void)fatal:(NSString *)format, ...;

@end
