//
//  DOLogging.h
//  DayOne
//
//  Created by Ben Dolman on 3/21/12.
//  Copyright (c) 2012 Bloom Built, LLC. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CocoaLumberjack/CocoaLumberjack.h>
#import <DOCore/DOLogFormatter.h>

/**
 * A string to be included at the beginning of a log session. Includes build/device information, as well
 * as local and Utah dates (for convenience in reading the log)
 */
extern NSString *DOLogHeaderMessage();

#ifndef DLog
    #if defined(DAYONE_DEBUG) || defined(DEBUG)
        #define DLog(frmt, ...) LOG_OBJC_MAYBE(LOG_ASYNC_DEBUG, LOG_LEVEL_DEBUG, LOG_FLAG_DEBUG, 0, frmt, ## __VA_ARGS__)
        #define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]
    #else
        #define DLog(...) do { } while (0)
        #ifndef NS_BLOCK_ASSERTIONS
        #define NS_BLOCK_ASSERTIONS
        #endif
        #define ALog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
    #endif

    #define ZAssert(condition, ...) do { if (!(condition)) { ALog(__VA_ARGS__); }} while(0)
#endif