2009-11-10 16:48:42 +01:00
|
|
|
#include "rar.hpp"
|
|
|
|
|
|
|
|
|
2020-07-15 00:40:26 +02:00
|
|
|
static wchar LogName[NM];
|
|
|
|
static RAR_CHARSET LogCharset=RCH_DEFAULT;
|
2009-11-10 16:48:42 +01:00
|
|
|
|
2020-07-15 00:40:26 +02:00
|
|
|
void InitLogOptions(const wchar *LogFileName,RAR_CHARSET CSet)
|
2009-11-10 16:48:42 +01:00
|
|
|
{
|
2020-07-15 00:40:26 +02:00
|
|
|
wcsncpyz(LogName,LogFileName,ASIZE(LogName));
|
|
|
|
LogCharset=CSet;
|
2009-11-10 16:48:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SILENT
|
2020-07-15 00:40:26 +02:00
|
|
|
void Log(const wchar *ArcName,const wchar *fmt,...)
|
2009-11-10 16:48:42 +01:00
|
|
|
{
|
2020-07-15 00:40:26 +02:00
|
|
|
// Preserve the error code for possible following system error message.
|
|
|
|
int Code=ErrHandler.GetSystemErrorCode();
|
|
|
|
|
|
|
|
uiAlarm(UIALARM_ERROR);
|
|
|
|
|
|
|
|
// This buffer is for format string only, not for entire output,
|
|
|
|
// so it can be short enough.
|
|
|
|
wchar fmtw[1024];
|
|
|
|
PrintfPrepareFmt(fmt,fmtw,ASIZE(fmtw));
|
|
|
|
|
|
|
|
safebuf wchar Msg[2*NM+1024];
|
|
|
|
va_list arglist;
|
|
|
|
va_start(arglist,fmt);
|
|
|
|
vswprintf(Msg,ASIZE(Msg),fmtw,arglist);
|
|
|
|
va_end(arglist);
|
|
|
|
eprintf(L"%ls",Msg);
|
|
|
|
ErrHandler.SetSystemErrorCode(Code);
|
2009-11-10 16:48:42 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|