OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Log.h File Reference
#include "lib/StdBuf.h"
Include dependency graph for C4Log.h:
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 100 of file C4Log.cpp.

References C4LogFile, and C4ShaderLogFile.

Referenced by C4Application::~C4Application().

101 {
102  // close
103  if (C4ShaderLogFile) fclose(C4ShaderLogFile); C4ShaderLogFile = nullptr;
104  if (C4LogFile) fclose(C4LogFile); C4LogFile = nullptr;
105  // ok
106  return true;
107 }
FILE * C4ShaderLogFile
Definition: C4Log.cpp:45
FILE * C4LogFile
Definition: C4Log.cpp:44

Here is the caller graph for this function:

bool DebugLog ( const char *  strMessage)

Definition at line 273 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().

274 {
275  if (Game.DebugMode)
276  return Log(strMessage);
277  else
278  return LogSilent(strMessage);
279 }
bool LogSilent(const char *szMessage, bool fConsole)
Definition: C4Log.cpp:117
C4Game Game
Definition: C4Globals.cpp:52
bool Log(const char *szMessage)
Definition: C4Log.cpp:195
bool DebugMode
Definition: C4Game.h:146

Here is the call graph for this function:

Here is the caller graph for this function:

bool DebugLogF ( const char *  strMessage...)

Definition at line 281 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().

282 {
283  va_list args; va_start(args, strMessage);
284  StdStrBuf Buf;
285  Buf.FormatV(strMessage, args);
286  return DebugLog(Buf.getData());
287 }
const char * getData() const
Definition: StdBuf.h:450
bool DebugLog(const char *strMessage)
Definition: C4Log.cpp:273
void FormatV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:189

Here is the call graph for this function:

Here is the caller graph for this function:

const char* GetFatalError ( )

Definition at line 248 of file C4Log.cpp.

References StdStrBuf::getData().

Referenced by C4Startup::DoStartup().

249 {
250  return sFatalError.getData();
251 }
const char * getData() const
Definition: StdBuf.h:450
StdStrBuf sFatalError
Definition: C4Log.cpp:49

Here is the call graph for this function:

Here is the caller graph for this function:

int GetLogFD ( )

Definition at line 109 of file C4Log.cpp.

References C4LogFile.

110 {
111  if (C4LogFile)
112  return fileno(C4LogFile);
113  else
114  return -1;
115 }
FILE * C4LogFile
Definition: C4Log.cpp:44
size_t GetLogPos ( )

Definition at line 289 of file C4Log.cpp.

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

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

290 {
291  // get current log position
292  return FileSize(sLogFileName.getData());
293 }
const char * getData() const
Definition: StdBuf.h:450
StdStrBuf sLogFileName
Definition: C4Log.cpp:47
size_t FileSize(const char *szFilename)
Definition: StdFile.cpp:448

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 295 of file C4Log.cpp.

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

Referenced by C4Startup::DoStartup().

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

Here is the call graph for this function:

Here is the caller graph for this function:

bool Log ( const char *  szMessage)

Definition at line 195 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().

196 {
197  if (!Application.AssertMainThread()) return false;
198  if (iDisableLog) return true;
199  // security
200  if (!szMessage) return false;
201 
202 #ifndef NOAULDEBUG
203  // Pass on to debugger
204  if (C4AulDebug *pDebug = C4AulDebug::GetDebugger())
205  pDebug->OnLog(szMessage);
206 #endif
207  // Pass on to console
208  Console.Out(szMessage);
209  // pass on to lobby
211  if (pLobby) pLobby->OnLog(szMessage);
212 
213  // Add message to log buffer
214  bool fNotifyMsgBoard = false;
216  {
217  ::GraphicsSystem.MessageBoard->AddLog(szMessage);
218  fNotifyMsgBoard = true;
219  }
220 
221  // log
222  LogSilent(szMessage, true);
223 
224  // Notify message board
225  if (fNotifyMsgBoard) ::GraphicsSystem.MessageBoard->LogNotify();
226 
227  return true;
228 }
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:117
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:689
std::unique_ptr< C4MessageBoard > MessageBoard
int iDisableLog
Definition: C4Log.cpp:193
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

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

Definition at line 253 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().

254 {
255  va_list args; va_start(args, strMessage);
256  // Compose formatted message
257  StdStrBuf Buf;
258  Buf.FormatV(strMessage, args);
259  // Log
260  return Log(Buf.getData());
261 }
const char * getData() const
Definition: StdBuf.h:450
bool Log(const char *szMessage)
Definition: C4Log.cpp:195
void FormatV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:189

Here is the call graph for this function:

bool LogFatal ( const char *  szMessage)

Definition at line 230 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().

231 {
232  if (!szMessage) szMessage = "(null)";
233  // add to fatal error message stack - if not already in there (avoid duplication)
234  if (!SSearch(sFatalError.getData(), szMessage))
235  {
237  sFatalError.Append(szMessage);
238  }
239  // write to log - note that Log might overwrite a static buffer also used in szMessage
240  return !!Log(FormatString(LoadResStr("IDS_ERR_FATAL"), szMessage).getData());
241 }
const char * getData() const
Definition: StdBuf.h:450
StdStrBuf sFatalError
Definition: C4Log.cpp:49
const char * SSearch(const char *szString, const char *szIndex)
Definition: Standard.cpp:333
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void AppendChar(char cChar)
Definition: StdBuf.h:596
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
bool isNull() const
Definition: StdBuf.h:449
bool Log(const char *szMessage)
Definition: C4Log.cpp:195
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

Here is the call graph for this function:

Here is the caller graph for this function:

bool LogSilent ( const char *  szMessage)

Definition at line 188 of file C4Log.cpp.

References LogSilent().

189 {
190  return LogSilent(szMessage, false);
191 }
bool LogSilent(const char *szMessage, bool fConsole)
Definition: C4Log.cpp:117

Here is the call graph for this function:

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

Definition at line 263 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().

264 {
265  va_list args; va_start(args, strMessage);
266  // Compose formatted message
267  StdStrBuf Buf;
268  Buf.FormatV(strMessage, args);
269  // Log
270  return LogSilent(Buf.getData());
271 }
const char * getData() const
Definition: StdBuf.h:450
bool LogSilent(const char *szMessage, bool fConsole)
Definition: C4Log.cpp:117
void FormatV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:189

Here is the call graph for this function:

Here is the caller graph for this function:

bool OpenExtraLogs ( )

Definition at line 76 of file C4Log.cpp.

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

Referenced by C4Application::DoInit().

77 {
78  // shader log in editor mode (only one file)
79  bool success = true;
80  if (C4Shader::IsLogging())
81  {
82 #ifdef _WIN32
83  C4ShaderLogFile = _fsopen(Config.AtUserDataPath(C4CFN_LogShader), "wt", _SH_DENYWR);
84 #elif defined(HAVE_SYS_FILE_H)
86  if (C4ShaderLogFile && flock(fileno(C4ShaderLogFile), LOCK_EX | LOCK_NB) != 0)
87  {
88  DebugLog("Couldn't lock shader log file, closing.");
89  fclose(C4ShaderLogFile);
90  C4ShaderLogFile = nullptr;
91  }
92 #else
93  C4ShaderLogFile = fopen(Config.AtUserDataPath(C4CFN_LogShader), "wb");
94 #endif
95  if (!C4ShaderLogFile) success = false;
96  }
97  return success;
98 }
FILE * C4ShaderLogFile
Definition: C4Log.cpp:45
C4Config Config
Definition: C4Config.cpp:837
bool DebugLog(const char *strMessage)
Definition: C4Log.cpp:273
static bool IsLogging()
Definition: C4Shader.cpp:667
const char * AtUserDataPath(const char *szFilename)
Definition: C4Config.cpp:530
#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 51 of file C4Log.cpp.

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

Referenced by C4Application::DoInit().

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

References StdStrBuf::Clear().

Referenced by C4Startup::DoStartup().

244 {
245  sFatalError.Clear();
246 }
StdStrBuf sFatalError
Definition: C4Log.cpp:49
void Clear()
Definition: StdBuf.h:474

Here is the call graph for this function:

Here is the caller graph for this function:

bool ShaderLog ( const char *  strMessage)

Definition at line 334 of file C4Log.cpp.

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

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

335 {
336  // security
337  if (!C4ShaderLogFile) return false;
338  if (!Application.AssertMainThread()) return false;
339  if (!szMessage) return false;
340  // output into shader log file
341  fputs(szMessage, C4ShaderLogFile);
342  fputs("\n", C4ShaderLogFile);
343  fflush(C4ShaderLogFile);
344  return true;
345 }
bool AssertMainThread()
Definition: C4App.h:123
FILE * C4ShaderLogFile
Definition: C4Log.cpp:45
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 347 of file C4Log.cpp.

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

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

348 {
349  va_list args; va_start(args, strMessage);
350  StdStrBuf Buf;
351  Buf.FormatV(strMessage, args);
352  return ShaderLog(Buf.getData());
353 }
const char * getData() const
Definition: StdBuf.h:450
bool ShaderLog(const char *szMessage)
Definition: C4Log.cpp:334
void FormatV(const char *szFmt, va_list args)
Definition: StdBuf.cpp:189

Here is the call graph for this function:

Here is the caller graph for this function: