log.cpp 814 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "rar.hpp"
  2. static wchar LogName[NM];
  3. static RAR_CHARSET LogCharset=RCH_DEFAULT;
  4. void InitLogOptions(const wchar *LogFileName,RAR_CHARSET CSet)
  5. {
  6. wcsncpyz(LogName,LogFileName,ASIZE(LogName));
  7. LogCharset=CSet;
  8. }
  9. #ifndef SILENT
  10. void Log(const wchar *ArcName,const wchar *fmt,...)
  11. {
  12. // Preserve the error code for possible following system error message.
  13. int Code=ErrHandler.GetSystemErrorCode();
  14. uiAlarm(UIALARM_ERROR);
  15. // This buffer is for format string only, not for entire output,
  16. // so it can be short enough.
  17. wchar fmtw[1024];
  18. PrintfPrepareFmt(fmt,fmtw,ASIZE(fmtw));
  19. safebuf wchar Msg[2*NM+1024];
  20. va_list arglist;
  21. va_start(arglist,fmt);
  22. vswprintf(Msg,ASIZE(Msg),fmtw,arglist);
  23. va_end(arglist);
  24. eprintf(L"%ls",Msg);
  25. ErrHandler.SetSystemErrorCode(Code);
  26. }
  27. #endif