OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Log.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool OpenLog ()
 
bool OpenExtraLogs ()
 
bool CloseLog ()
 
bool Log (const char *szMessage)
 
bool LogSilent (const char *szMessage)
 
bool LogF (const char *strMessage,...) GNUC_FORMAT_ATTRIBUTE
 
bool LogSilentF (const char *strMessage,...) GNUC_FORMAT_ATTRIBUTE
 
bool DebugLog (const char *strMessage)
 
bool DebugLogF (const char *strMessage...) GNUC_FORMAT_ATTRIBUTE
 
bool ShaderLog (const char *strMessage)
 
bool ShaderLogF (const char *strMessage...) GNUC_FORMAT_ATTRIBUTE
 
bool LogFatal (const char *szMessage)
 
void ResetFatalError ()
 
const char * GetFatalError ()
 
size_t GetLogPos ()
 
bool GetLogSection (size_t iStart, size_t iLength, StdStrBuf &rsOut)
 
int GetLogFD ()
 

Function Documentation

bool CloseLog ( )

Definition at line 97 of file C4Log.cpp.

References C4LogFile, and C4ShaderLogFile.

Referenced by C4Application::~C4Application().

98 {
99  // close
100  if (C4ShaderLogFile) fclose(C4ShaderLogFile); C4ShaderLogFile = nullptr;
101  if (C4LogFile) fclose(C4LogFile); C4LogFile = nullptr;
102  // ok
103  return true;
104 }
FILE * C4ShaderLogFile
Definition: C4Log.cpp:42
FILE * C4LogFile
Definition: C4Log.cpp:41

Here is the caller graph for this function:

bool DebugLog ( const char *  strMessage)

Definition at line 270 of file C4Log.cpp.

References C4Game::DebugMode, Game, Log(), and LogSilent().

Referenced by DebugLogF(), C4AulScriptContext::dump(), C4Game::LoadScenarioComponents(), C4Game::LoadScenarioSection(), OpenExtraLogs(), C4InteractiveThread::ProcessEvents(), and C4PropListScen::SetPropertyByS().

271 {
272  if (Game.DebugMode)
273  return Log(strMessage);
274  else
275  return LogSilent(strMessage);
276 }
bool LogSilent(const char *szMessage, bool fConsole)
Definition: C4Log.cpp:114
C4Game Game
Definition: C4Globals.cpp:52
bool Log(const char *szMessage)
Definition: C4Log.cpp:192
bool DebugMode
Definition: C4Game.h:144

Here is the call graph for this function:

Here is the caller graph for this function:

bool DebugLogF ( const char *  strMessage...)

Definition at line 278 of file C4Log.cpp.

References DebugLog(), StdStrBuf::FormatV(), and StdStrBuf::getData().

Referenced by C4MaterialMap::CrossMapMaterials(), C4ScenarioListLoader::SubFolder::DoLoadContents(), C4ScenarioListLoader::RegularFolder::DoLoadContents(), C4RoundResults::EvaluateGame(), C4GameObjects::FixObjectOrder(), C4AulExec::FnTranslate(), C4TextureMap::GetIndex(), C4TextureMap::GetIndexMatTex(), C4Object::GetInfoString(), C4TexMapEntry::Init(), C4ParticleDef::Load(), C4MapFolderData::Load(), C4DefGraphics::LoadBitmap(), C4Def::LoadDefCore(), C4TextureMap::LoadMap(), C4DefGraphics::LoadMesh(), C4Game::LoadScenarioSection(), C4DefGraphics::LoadSkeleton(), C4SoundSystem::NewEffect(), C4GameObjects::PostLoad(), C4MaterialReaction::ResolveScriptFuncs(), C4Landscape::SetTextureIndex(), StdCompilerWarnCallback(), and StdMeshMaterialParserCtx::WarningNotSupported().

279 {
280  va_list args; va_start(args, strMessage);
281  StdStrBuf Buf;
282  Buf.FormatV(strMessage, args);
283  return DebugLog(Buf.getData());
284 }
const char * getData() const
Definition: StdBuf.h:442
bool DebugLog(const char *strMessage)
Definition: C4Log.cpp:270
void FormatV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:182

Here is the call graph for this function:

Here is the caller graph for this function:

const char* GetFatalError ( )

Definition at line 245 of file C4Log.cpp.

References StdStrBuf::getData().

Referenced by C4Startup::DoStartup().

246 {
247  return sFatalError.getData();
248 }
const char * getData() const
Definition: StdBuf.h:442
StdStrBuf sFatalError
Definition: C4Log.cpp:46

Here is the call graph for this function:

Here is the caller graph for this function:

int GetLogFD ( )

Definition at line 106 of file C4Log.cpp.

References C4LogFile.

107 {
108  if (C4LogFile)
109  return fileno(C4LogFile);
110  else
111  return -1;
112 }
FILE * C4LogFile
Definition: C4Log.cpp:41
size_t GetLogPos ( )

Definition at line 286 of file C4Log.cpp.

References FileSize(), and StdStrBuf::getData().

Referenced by C4Game::Clear(), and C4Game::Init().

287 {
288  // get current log position
289  return FileSize(sLogFileName.getData());
290 }
const char * getData() const
Definition: StdBuf.h:442
StdStrBuf sLogFileName
Definition: C4Log.cpp:44
size_t FileSize(const char *fname)

Here is the call graph for this function:

Here is the caller graph for this function:

bool GetLogSection ( size_t  iStart,
size_t  iLength,
StdStrBuf rsOut 
)

Definition at line 292 of file C4Log.cpp.

References StdStrBuf::Clear(), StdStrBuf::Copy(), StdStrBuf::getData(), StdStrBuf::getMData(), StdStrBuf::getSize(), iSize, and StdStrBuf::LoadFromFile().

Referenced by C4Startup::DoStartup().

293 {
294  if (!iLength) { rsOut.Clear(); return true; }
295  // read section from log file
296  StdStrBuf BufOrig;
297  if (!BufOrig.LoadFromFile(sLogFileName.getData())) return false;
298  char *szBuf = BufOrig.getMData();
299  size_t iSize = BufOrig.getSize(); // size excluding terminator
300  // reduce to desired buffer section
301  if (iStart > iSize) iStart = iSize;
302  if (iStart + iLength > iSize) iLength = iSize - iStart;
303  szBuf += iStart; szBuf[iLength] = '\0';
304  // strip timestamps; convert linebreaks to Clonk-linebreaks '|'
305  char *szPosWrite=szBuf; const char *szPosRead=szBuf;
306  while (*szPosRead)
307  {
308  // skip timestamp
309  if (*szPosRead == '[')
310  while (*szPosRead && *szPosRead != ']') { --iSize; ++szPosRead; }
311  // skip whitespace behind timestamp
312  if (!*szPosRead) break;
313  szPosRead++;
314  // copy data until linebreak
315  size_t iLen=0;
316  while (*szPosRead && *szPosRead != 0x0d && *szPosRead != 0x0a)
317  { ++szPosRead; ++iLen; }
318  if (iLen && szPosRead-iLen != szPosWrite) memmove(szPosWrite, szPosRead-iLen, iLen);
319  szPosWrite += iLen;
320  // skip additional linebreaks
321  while (*szPosRead == 0x0d || *szPosRead == 0x0a) ++szPosRead;
322  // write a Clonk-linebreak
323  if (*szPosRead) *szPosWrite++ = '|';
324  }
325  // done; create string buffer from data
326  rsOut.Copy(szBuf, szPosWrite - szBuf);
327  // done, success
328  return true;
329 }
const char * getData() const
Definition: StdBuf.h:442
StdStrBuf sLogFileName
Definition: C4Log.cpp:44
void Clear()
Definition: StdBuf.h:466
char * getMData()
Definition: StdBuf.h:443
bool LoadFromFile(const char *szFile)
Definition: StdBuf.cpp:73
size_t getSize() const
Definition: StdBuf.h:444
void Copy()
Definition: StdBuf.h:467
int iSize
Definition: TstC4NetIO.cpp:32

Here is the call graph for this function:

Here is the caller graph for this function:

bool Log ( const char *  szMessage)

Definition at line 192 of file C4Log.cpp.

References Application, C4AbstractApp::AssertMainThread(), Console, first_log, fQuiet, C4AulDebug::GetDebugger(), C4Network2::GetLobby(), GraphicsSystem, iDisableLog, LogSilent(), C4GraphicsSystem::MessageBoard, n_logs, Network, C4GameLobby::MainDlg::OnLog(), and C4ConsoleGUI::Out().

Referenced by C4GameLobby::Countdown::Abort(), C4ClientList::Add(), C4Network2ResList::AddByFile(), C4Network2ResList::AddByGroup(), C4PlayerInfoList::AssignPlayerIDs(), C4Network2IO::Broadcast(), C4ClientPlayerInfos::C4ClientPlayerInfos(), C4GamePadControl::C4GamePadControl(), C4Game::CanQuickSave(), C4Playback::Check(), C4ObjectList::CheckSort(), C4Application::Clear(), C4Game::Clear(), ConsoleDlgProc(), C4AbstractApp::Copy(), C4GameLobby::Countdown::Countdown(), CStdGL::CreateContext(), C4Network2::CreateDynamic(), DebugLog(), C4Network2Res::Derive(), C4Game::DoGameOver(), C4Application::DoInit(), C4Network2::DoLobby(), C4Player::Eliminate(), C4Draw::Error(), C4Game::Evaluate(), C4GameControl::ExecControl(), C4GameControl::ExecControlPacket(), C4Network2::FinalInit(), FullScreenWinProc(), C4Network2Res::GetStandalone(), C4Network2Players::HandlePlayerInfoUpdRequest(), C4Game::Init(), C4Game::InitControl(), C4Game::InitDefs(), C4Game::InitGame(), C4Game::InitNetworkFromAddress(), C4PlayerList::Join(), C4Network2::LeagueEnd(), C4Network2::LeaguePlrAuth(), C4Network2::LeaguePlrAuthCheck(), C4Network2::LeagueStart(), C4Network2::LeagueUpdateProcessReply(), C4Network2::LeagueWaitNotBusy(), C4AulDebug::Listen(), C4SoundEffect::Load(), C4ParticleDef::Load(), C4Config::Load(), C4Game::LoadAdditionalSystemGroup(), C4Extra::LoadDef(), C4Language::LoadLanguage(), C4GameLobby::LobbyError(), LogF(), LogFatal(), C4MainMenu::MenuCommand(), C4Network2::OnClientDisconnect(), C4GameOptionButtons::OnCommentSet(), C4GameLobby::Countdown::OnSec1Timer(), C4Game::OpenScenario(), C4Network2Res::OptimizeStandalone(), C4Application::ParseCommandLine(), C4Application::PreInit(), CStdGL::PrepareMaterial(), C4MessageInput::ProcessCommand(), C4InteractiveThread::ProcessEvents(), ProcessGroup(), C4MessageInput::ProcessInput(), C4Game::QuickSave(), C4Game::ReloadDef(), C4PlayerList::RemoveAtClient(), C4PlayerList::RemoveAtRemoteClient(), C4PlayerList::RemoveLocal(), CStdNoGfx::RestoreDeviceObjects(), C4PlayerInfoList::RestoreSavegameInfos(), C4GameSave::Save(), C4GameSaveSavegame::SaveComponents(), C4Player::SetHostility(), C4MCParserErr::show(), C4Record::Start(), C4Playback::StreamToRecord(), C4Playback::Strip(), C4Player::Surrender(), C4PlayerList::SynchronizeLocalFiles(), C4Network2::Vote(), and C4PropListNumbered::~C4PropListNumbered().

193 {
194  if (!Application.AssertMainThread()) return false;
195  if (iDisableLog) return true;
196  // security
197  if (!szMessage) return false;
198 
199 #ifndef NOAULDEBUG
200  // Pass on to debugger
201  if (C4AulDebug *pDebug = C4AulDebug::GetDebugger())
202  pDebug->OnLog(szMessage);
203 #endif
204  // Pass on to console
205  Console.Out(szMessage);
206  // pass on to lobby
208  if (pLobby) pLobby->OnLog(szMessage);
209 
210  // Add message to log buffer
211  bool fNotifyMsgBoard = false;
213  {
214  ::GraphicsSystem.MessageBoard->AddLog(szMessage);
215  fNotifyMsgBoard = true;
216  }
217 
218  // log
219  LogSilent(szMessage, true);
220 
221  // Notify message board
222  if (fNotifyMsgBoard) ::GraphicsSystem.MessageBoard->LogNotify();
223 
224  return true;
225 }
bool AssertMainThread()
Definition: C4App.h:123
class C4GameLobby::MainDlg * GetLobby() const
Definition: C4Network2.h:216
C4Console Console
Definition: C4Globals.cpp:45
bool LogSilent(const char *szMessage, bool fConsole)
Definition: C4Log.cpp:114
void OnLog(const char *szLogMsg, DWORD dwClr=C4GUI_LogFontClr)
C4Network2 Network
Definition: C4Globals.cpp:53
static C4AulDebug * GetDebugger()
Definition: C4AulDebug.h:31
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51
void Out(const char *message)
Definition: C4Console.cpp:684
std::unique_ptr< C4MessageBoard > MessageBoard
int iDisableLog
Definition: C4Log.cpp:190
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

bool LogF ( const char *  strMessage,
  ... 
)

Definition at line 250 of file C4Log.cpp.

References StdStrBuf::FormatV(), StdStrBuf::getData(), and Log().

Referenced by C4Group::AccessEntry(), C4MusicFile::Announce(), C4Application::ApplyResolutionConstraints(), C4ControlJoinPlayer::C4ControlJoinPlayer(), CStdGL::CheckGLError(), C4Network2UPnPP::ClearNatMappings(), CompileFromBuf_Log(), CompileFromBuf_LogWarn(), C4ObjectList::CompileFunc(), C4Game::CompileRuntimeData(), CStdGL::CreateContext(), C4FoWAmbient::CreateFromLandscape(), CreatePath(), C4PlayerInfoList::CreateRestoreInfosForJoinedScriptPlayers(), C4Playback::DebugRecError(), DecompileToBuf_Log(), C4Value::Denumerate(), C4Application::DoInit(), C4DownloadDlg::DownloadFile(), CStdGL::Error(), C4GameControlNetwork::ExecQueuedSyncCtrl(), C4GameControlNetwork::ExecSyncControl(), C4Control::Execute(), C4Player::Execute(), C4GUI::ExpandHotkeyMarkup(), C4ComponentHost::FinishLoad(), C4Network2Res::GetStandalone(), C4ValueNumbers::GetValue(), C4AchievementGraphics::Init(), C4AbstractApp::Init(), C4TextureMap::Init(), C4Network2IO::Init(), C4SoundModifierList::Init(), C4Player::Init(), C4Player::InitControl(), C4Game::InitDefs(), C4FontLoader::InitFont(), C4MusicSystem::InitForScenario(), C4MusicSystem::InitializeMOD(), C4Game::InitMaterialTexture(), C4Game::InitNetworkFromReference(), C4PlayerList::Join(), C4Network2::Join(), C4Network2::LeagueNotifyDisconnect(), C4Network2::LeaguePlrAuth(), C4Network2::LeagueShowError(), C4Network2::LeagueUpdate(), C4Game::LinkScriptEngine(), C4AulDebug::Listen(), C4TextureShape::Load(), C4DefList::Load(), C4Surface::Load(), C4Config::Load(), C4KeyboardInput::LoadCustomConfig(), C4Extra::LoadDef(), C4MusicSystem::LoadDir(), C4GraphicsResource::LoadFile(), C4PlayerInfo::LoadResource(), StdMeshSkeletonLoader::LoadSkeletonBinary(), C4TextureMap::LoadTextures(), C4PlayerInfoList::LocalJoinUnjoinedPlayersInQueue(), C4GUI::ComponentAligner::LogIt(), main(), C4Playback::Open(), C4Game::OpenScenario(), C4Value::operator==(), C4Network2Res::OptimizeStandalone(), C4Application::ParseCommandLine(), C4EditCursor::PerformDuplication(), C4MusicSystem::Play(), C4MusicFileSDL::Play(), C4Control::PreExecute(), C4MessageInput::ProcessCommand(), ProcessGroup(), Ogre::Mesh::Chunk::Read(), Ogre::Skeleton::Chunk::Read(), C4Playback::ReadBinary(), Ogre::Mesh::ChunkMesh::ReadImpl(), Ogre::Mesh::ChunkSubmesh::ReadImpl(), Ogre::Mesh::ChunkGeometry::ReadImpl(), Ogre::Skeleton::ChunkAnimation::ReadImpl(), C4PlayerInfoList::RecreatePlayerFiles(), C4PlayerInfoList::RecreatePlayers(), C4AulScriptEngine::ReLink(), C4Game::ReloadDef(), C4Game::ReloadParticle(), C4LSectors::Remove(), C4PlayerInfoList::RemoveUnassociatedPlayers(), C4LangStringTable::ReplaceStrings(), C4PlayerControlAssignment::ResolveRefs(), C4PlayerInfoList::RestoreSavegameInfos(), C4Network2::RetrieveRes(), C4Playback::ReWriteBinary(), C4ObjectInfo::Save(), C4GameSave::Save(), C4Player::Save(), C4Config::Save(), C4Game::SaveData(), C4GraphicsSystem::SaveScreenshot(), C4Player::ScenarioInit(), C4MusicSystem::ScheduleWaitTime(), C4Network2IOConnection::Send(), C4Network2ResChunk::Set(), C4Network2Res::SetByFile(), C4Object::SetOCF(), C4MusicSystem::SetPlayList(), C4Landscape::SetTextureIndex(), C4AbstractApp::SetVideoMode(), C4Playback::StreamToRecord(), C4Object::UpdateOCF(), and C4InVal::ValidateString().

251 {
252  va_list args; va_start(args, strMessage);
253  // Compose formatted message
254  StdStrBuf Buf;
255  Buf.FormatV(strMessage, args);
256  // Log
257  return Log(Buf.getData());
258 }
const char * getData() const
Definition: StdBuf.h:442
bool Log(const char *szMessage)
Definition: C4Log.cpp:192
void FormatV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:182

Here is the call graph for this function:

bool LogFatal ( const char *  szMessage)

Definition at line 227 of file C4Log.cpp.

References StdStrBuf::Append(), StdStrBuf::AppendChar(), FormatString(), StdStrBuf::getData(), StdStrBuf::isNull(), LoadResStr(), Log(), and SSearch().

Referenced by C4Game::CheckObjectEnumeration(), C4Network2ResList::CreateNetworkFolder(), C4MaterialMap::CrossMapMaterials(), C4Application::DoInit(), C4GameControlNetwork::DoInput(), C4Startup::EnsureLoaded(), C4GameControl::Execute(), C4Network2::HandleJoinData(), C4LoaderScreen::Init(), C4Network2IO::Init(), C4GraphicsResource::Init(), C4LandscapeRenderGL::Init(), C4Game::Init(), C4Game::InitControl(), C4Game::InitDefs(), C4FontLoader::InitFont(), C4StartupGraphics::InitFonts(), C4Game::InitGame(), C4Network2::InitHost(), C4Network2::InitLeague(), C4Game::InitMaterialTexture(), C4GameRes::InitNetwork(), C4Game::InitNetworkFromAddress(), C4Game::InitNetworkFromReference(), C4Game::InitNetworkHost(), C4Game::InitPlayerControlSettings(), C4Game::InitPlayers(), C4GameControl::InitReplay(), C4Game::InitScriptEngine(), C4Network2::LeagueStart(), C4AulDebug::Listen(), C4DefList::Load(), C4Landscape::Load(), C4GameParameters::Load(), C4Game::LoadScenarioComponents(), C4Playback::Open(), C4Game::OpenScenario(), C4Application::PreInit(), C4Game::PreInit(), C4InteractiveThread::ProcessEvents(), C4GraphicsResource::RegisterGlobalGraphics(), C4GroupSet::RegisterParentFolders(), C4LandscapeRenderGL::ReInit(), C4PlayerControlAssignment::ResolveRefs(), and C4Network2::RetrieveRes().

228 {
229  if (!szMessage) szMessage = "(null)";
230  // add to fatal error message stack - if not already in there (avoid duplication)
231  if (!SSearch(sFatalError.getData(), szMessage))
232  {
234  sFatalError.Append(szMessage);
235  }
236  // write to log - note that Log might overwrite a static buffer also used in szMessage
237  return !!Log(FormatString(LoadResStr("IDS_ERR_FATAL"), szMessage).getData());
238 }
const char * getData() const
Definition: StdBuf.h:442
StdStrBuf sFatalError
Definition: C4Log.cpp:46
const char * SSearch(const char *szString, const char *szIndex)
Definition: Standard.cpp:341
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void AppendChar(char cChar)
Definition: StdBuf.h:588
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
bool isNull() const
Definition: StdBuf.h:441
bool Log(const char *szMessage)
Definition: C4Log.cpp:192
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270

Here is the call graph for this function:

Here is the caller graph for this function:

bool LogSilent ( const char *  szMessage)

Definition at line 185 of file C4Log.cpp.

References LogSilent().

186 {
187  return LogSilent(szMessage, false);
188 }
bool LogSilent(const char *szMessage, bool fConsole)
Definition: C4Log.cpp:114

Here is the call graph for this function:

bool LogSilentF ( const char *  strMessage,
  ... 
)

Definition at line 260 of file C4Log.cpp.

References StdStrBuf::FormatV(), StdStrBuf::getData(), and LogSilent().

Referenced by C4FoWLightSection::CalculateTriangles(), C4Network2::ChangeGameStatus(), C4ConfigNetwork::CheckPortsForCollisions(), C4Network2Res::Clear(), C4GUI::ConfirmationDialog::ConfirmationDialog(), C4Network2IO::Connect(), CStdGL::CreateContext(), C4Network2Client::DoConnectAttempt(), C4Network2Res::GetStandalone(), C4Network2::HandleConn(), C4Network2::HandleConnRe(), C4Network2::HandleJoinData(), C4Network2::HandleStatus(), C4Network2IO::Init(), C4Network2::OnClientDisconnect(), C4Network2::OnConnect(), C4Network2::OnConnectFail(), C4Network2::OnDisconn(), C4Network2::OnDisconnect(), C4Network2::OnStatusAck(), C4Network2Res::SetByFile(), C4Network2Res::SetByGroup(), C4MainStat::Show(), C4GUI::Screen::ShowMessage(), C4GUI::Screen::ShowMessageModal(), C4MainStat::ShowPart(), C4Game::Synchronize(), and C4FoWLightSection::Update().

261 {
262  va_list args; va_start(args, strMessage);
263  // Compose formatted message
264  StdStrBuf Buf;
265  Buf.FormatV(strMessage, args);
266  // Log
267  return LogSilent(Buf.getData());
268 }
const char * getData() const
Definition: StdBuf.h:442
bool LogSilent(const char *szMessage, bool fConsole)
Definition: C4Log.cpp:114
void FormatV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:182

Here is the call graph for this function:

Here is the caller graph for this function:

bool OpenExtraLogs ( )

Definition at line 73 of file C4Log.cpp.

References C4Config::AtUserDataPath(), C4CFN_LogShader, C4ShaderLogFile, Config, DebugLog(), and C4Shader::IsLogging().

Referenced by C4Application::DoInit().

74 {
75  // shader log in editor mode (only one file)
76  bool success = true;
77  if (C4Shader::IsLogging())
78  {
79 #ifdef _WIN32
80  C4ShaderLogFile = _fsopen(Config.AtUserDataPath(C4CFN_LogShader), "wt", _SH_DENYWR);
81 #elif defined(HAVE_SYS_FILE_H)
83  if (C4ShaderLogFile && flock(fileno(C4ShaderLogFile), LOCK_EX | LOCK_NB) != 0)
84  {
85  DebugLog("Couldn't lock shader log file, closing.");
86  fclose(C4ShaderLogFile);
87  C4ShaderLogFile = nullptr;
88  }
89 #else
90  C4ShaderLogFile = fopen(Config.AtUserDataPath(C4CFN_LogShader), "wb");
91 #endif
92  if (!C4ShaderLogFile) success = false;
93  }
94  return success;
95 }
FILE * C4ShaderLogFile
Definition: C4Log.cpp:42
C4Config Config
Definition: C4Config.cpp:833
bool DebugLog(const char *strMessage)
Definition: C4Log.cpp:270
static bool IsLogging()
Definition: C4Shader.cpp:663
const char * AtUserDataPath(const char *szFilename)
Definition: C4Config.cpp:526
#define C4CFN_LogShader
Definition: C4Components.h:143

Here is the call graph for this function:

Here is the caller graph for this function:

bool OpenLog ( )

Definition at line 48 of file C4Log.cpp.

References C4Config::AtUserDataPath(), C4CFN_Log, C4CFN_LogEx, C4LogFile, C4LogStartTime, Config, StdStrBuf::Format(), and StdStrBuf::getData().

Referenced by C4Application::DoInit().

49 {
50  // open
51  sLogFileName = C4CFN_Log; int iLog = 2;
52 #ifdef _WIN32
53  while (!(C4LogFile = _fsopen(Config.AtUserDataPath(sLogFileName.getData()), "wt", _SH_DENYWR)))
54 #elif defined(HAVE_SYS_FILE_H)
55  while (!(C4LogFile = fopen(Config.AtUserDataPath(sLogFileName.getData()), "wb")) || flock(fileno(C4LogFile),LOCK_EX|LOCK_NB))
56 #else
57  while (!(C4LogFile = fopen(Config.AtUserDataPath(sLogFileName.getData()), "wb")))
58 #endif
59  {
60  if(C4LogFile) fclose(C4LogFile); // Already locked by another instance?
61  // If the file does not yet exist, the directory is r/o
62  // don't go on then, or we have an infinite loop
63  if (access(Config.AtUserDataPath(sLogFileName.getData()), 0))
64  return false;
65  // try different name
67  }
68  // save start time
69  time(&C4LogStartTime);
70  return true;
71 }
const char * getData() const
Definition: StdBuf.h:442
C4Config Config
Definition: C4Config.cpp:833
time_t C4LogStartTime
Definition: C4Log.cpp:43
StdStrBuf sLogFileName
Definition: C4Log.cpp:44
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174
#define C4CFN_Log
Definition: C4Components.h:141
const char * AtUserDataPath(const char *szFilename)
Definition: C4Config.cpp:526
FILE * C4LogFile
Definition: C4Log.cpp:41
#define C4CFN_LogEx
Definition: C4Components.h:142

Here is the call graph for this function:

Here is the caller graph for this function:

void ResetFatalError ( )

Definition at line 240 of file C4Log.cpp.

References StdStrBuf::Clear().

Referenced by C4Startup::DoStartup().

241 {
242  sFatalError.Clear();
243 }
StdStrBuf sFatalError
Definition: C4Log.cpp:46
void Clear()
Definition: StdBuf.h:466

Here is the call graph for this function:

Here is the caller graph for this function:

bool ShaderLog ( const char *  strMessage)

Definition at line 331 of file C4Log.cpp.

References Application, C4AbstractApp::AssertMainThread(), and C4ShaderLogFile.

Referenced by C4Shader::Init(), and ShaderLogF().

332 {
333  // security
334  if (!C4ShaderLogFile) return false;
335  if (!Application.AssertMainThread()) return false;
336  if (!szMessage) return false;
337  // output into shader log file
338  fputs(szMessage, C4ShaderLogFile);
339  fputs("\n", C4ShaderLogFile);
340  fflush(C4ShaderLogFile);
341  return true;
342 }
bool AssertMainThread()
Definition: C4App.h:123
FILE * C4ShaderLogFile
Definition: C4Log.cpp:42
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function:

bool ShaderLogF ( const char *  strMessage...)

Definition at line 344 of file C4Log.cpp.

References StdStrBuf::FormatV(), StdStrBuf::getData(), and ShaderLog().

Referenced by C4Shader::Init(), and C4Shader::Refresh().

345 {
346  va_list args; va_start(args, strMessage);
347  StdStrBuf Buf;
348  Buf.FormatV(strMessage, args);
349  return ShaderLog(Buf.getData());
350 }
const char * getData() const
Definition: StdBuf.h:442
bool ShaderLog(const char *szMessage)
Definition: C4Log.cpp:331
void FormatV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:182

Here is the call graph for this function:

Here is the caller graph for this function: