#ifndef _FSysLog_H
#define _FSysLog_H

#include <stdarg.h>
#include "TimTypes.h"
#include "kernel.h"

#ifdef MAKEABS
#define USELOG
#else
#undef USELOG
#endif

const _kernel_oserror* SysLog_Init(GlobHdr* g, void* pw);
const _kernel_oserror* SysLog_Finalize(GlobHdr* g, void* pw);
int SysLog_LogLevel(void);
void SysLog_SetLogLevel(int level);

#define SysLog_High    80
#define SysLog_Medium 160
#define SysLog_Low    240


#ifdef USELOG

#ifdef __CC_NORCROFT
#pragma -v1 // hint to the compiler to check f/s/printf format
#endif
void SysLog_Log(int level, const char* pformat, ...);
#ifdef __CC_NORCROFT
#pragma -v0 // return to default
#endif

void SysLog_VFileError(SongHdr* pSong, int32_t file_offset, const char* pformat, va_list arg);
void SysLog_VFileCorrupted(int level, SongHdr* pSong, int32_t file_offset, const char* pformat, va_list arg);
#ifdef __CC_NORCROFT
#pragma -v1 // hint to the compiler to check f/s/printf format
#endif
void SysLog_FileError(SongHdr* pSong, int32_t file_offset, const char* pformat, ...);
void SysLog_FileCorrupted(int level, SongHdr* pSong, int32_t file_offset, const char* pformat, ...);
#ifdef __CC_NORCROFT
#pragma -v0 // return to default
#endif
void SysLog_WatchEffect(SongHdr* pSong, int32_t file_offset, uint32_t cmd, uint32_t value);
void SysLog_BadNote(SongHdr* pSong, int32_t file_offset, uint32_t channel, uint32_t note);
void SysLog_SkipEffect(SongHdr* pSong, int32_t file_offset, uint32_t cmd, uint32_t value);
void SysLog_SkipEffectValue(SongHdr* pSong, int32_t file_offset, uint32_t cmd, uint32_t value);
void SysLog_BadEffect(SongHdr* pSong, int32_t file_offset, uint32_t cmd, uint32_t value);
void SysLog_BadEffectValue(SongHdr* pSong, int32_t file_offset, uint32_t cmd, uint32_t value);

void SysLog_PlayEvent(ISong* s, int channel);
void SysLog_LogBinary(const char* desc, const uint8_t* pdata, int len);

#else
#define SysLog_Log(level, ...)
#define SysLog_VFileError(pSong, file_offset, pformat, arg)
#define SysLog_VFileCorrupted(level, pSong, file_offset, pformat, arg)
#define SysLog_FileError(pSong, file_offset, ...)
#define SysLog_FileCorrupted(level, pSong, file_offset, ...)
#define SysLog_WatchEffect(pSong, file_offset, cmd, value)
#define SysLog_BadNote(pSong, file_offset, channel, note)
#define SysLog_SkipEffect(pSong, file_offset, cmd, value)
#define SysLog_SkipEffectValue(pSong, file_offset, cmd, value)
#define SysLog_BadEffect(pSong, file_offset, cmd, value)
#define SysLog_BadEffectValue(pSong, file_offset, cmd, value)
#define SysLog_PlayEvent(s, channel)
#define SysLog_LogBinary(desc, pdata, len)
#endif

#endif
