/*

 Owner: Peter Baumgartner <peter@boinx.com>
 Company: Boinx Software Ltd., Germany
 Projects: BXBase, BXQuartzComposer, PhotoPresenter/Quartz Composer PlugIns, LightLoupe (PhotoBox), SeeThis

 Abstract: <#abstract#>

 Related: <#related#>

 Documentation: <#link to documentation#>

 */



/******************************************************************************************************

	BXLog.h
    Boinx Utility Framework
	
 ******************************************************************************************************

	Author:			Peter Baumgartner		Tel:  (+4989) 649-43875
					Rosskopfstr. 20			Mail: peter@baumgartner.com
					82031 Grünwald			
					Germany					
	
	Description:	Provides logging to stdio and logfile...
					
					Copyright © 2005 by Peter Baumgartner - All Rights Reserved

 ******************************************************************************************************/

/******************************************************************************************************
	READ ME
 ******************************************************************************************************/

	#pragma mark READ ME

	// Provides logging to stdio and logfile...


	#import <Foundation/Foundation.h>

/******************************************************************************************************
	CONSTANTS
 ******************************************************************************************************/

	#pragma mark CONSTANTS
		
	enum BXLogDestination
	{
		kBXLogDestinationNone,
		kBXLogDestinationFile,
		kBXLogDestinationFileAndConsole
	};
	
	
	// Domain array...
	
	#define kDomainCount 128
	#define kLogDomainFramework kDomainCount-1
	extern NSInteger sDomainLevel[kDomainCount];

	
/******************************************************************************************************
	FUNCTIONS
 ******************************************************************************************************/

	#pragma mark FUNCTIONS
	
	#if defined(__cplusplus)
    extern "C" {
	#endif

	void BXLogSetDefaultDestination();
	void BXLogSetDestination(NSInteger destination);
	NSInteger BXLogDestination();
	NSString *BXLogPath();

	void BXLogSetDomainLevel(NSInteger domain, NSInteger level);
	NSInteger BXLogDomainLevel(NSInteger domain);
	
	Boolean BXLogOpen(NSString *path);// Returns true if it opened a log file. Returns false, if it can't open a log file or a log file is already open.
	void BXLogClose();
			
	void BXLog(NSString *format, ...) NS_FORMAT_FUNCTION(1, 2);
	void BXLogError(OSStatus error, const char *message, const char *file, NSInteger line);
	
	// Get content of bx log file
	NSString *BXLogContent(void);
	
 	#ifdef __cplusplus
 	}
 	#endif	

	#ifndef BXLogErr
	#define BXLogErr(error) BXLogError(error, NULL, __FILE__, __LINE__)
	#endif
	
	#ifndef BXLogErrWithMessage
	#define BXLogErrWithMessage(error, message) BXLogError(error, message, __FILE__, __LINE__)
	#endif
	
	#ifndef BXLogErrorCode
	#define BXLogErrorCode(error) BXLogError(error, NULL, __PRETTY_FUNCTION__, __LINE__)
	#endif
	
	#ifndef BXLogErrorMessage
	#define BXLogErrorMessage(error, message) BXLogError(error, message, __PRETTY_FUNCTION__, __LINE__)
	#endif
	
	#ifndef BXLogIf
	#define BXLogIf(condition, format, args...) if (condition) BXLog(format, ##args)
	#endif

	#ifndef BXLogInDomain
	#define BXLogInDomain(domain, level, format, args...) if (sDomainLevel[domain] >= level) BXLog(format, ##args)
	#endif



/******************************************************************************************************/
