Skip to content

Commit

Permalink
libdeng2: Added LegacyCore_LogAs() to the C wrapper API
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Jul 24, 2012
1 parent fd5a8d5 commit 80b46cb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions doomsday/libdeng2/include/de/c_wrapper.h
Expand Up @@ -80,6 +80,7 @@ DENG2_PUBLIC void LegacyCore_Stop(int exitCode);
DENG2_PUBLIC void LegacyCore_Timer(unsigned int milliseconds, void (*callback)(void));
DENG2_PUBLIC int LegacyCore_SetLogFile(const char* filePath);
DENG2_PUBLIC const char* LegacyCore_LogFile();
DENG2_PUBLIC void LegacyCore_LogAs(const char* sectionName);
DENG2_PUBLIC void LegacyCore_PrintLogFragment(const char* text);
DENG2_PUBLIC void LegacyCore_PrintfLogFragmentAtLevel(legacycore_loglevel_t level, const char* format, ...);
DENG2_PUBLIC void LegacyCore_SetTerminateFunc(void (*func)(const char*));
Expand Down
2 changes: 1 addition & 1 deletion doomsday/libdeng2/include/de/core/log.h
Expand Up @@ -41,7 +41,7 @@
/// a new log section with a std::string variable based name.
#define LOG_AS_STRING(str) \
de::String __logSectionName = str; \
LOG_AS(__logSectionName.c_str());
LOG_AS(__logSectionName.toAscii().constData());

#define LOG_TRACE(str) LOG().enter(de::Log::TRACE, str)
#define LOG_DEBUG(str) LOG().enter(de::Log::DEBUG, str)
Expand Down
10 changes: 10 additions & 0 deletions doomsday/libdeng2/include/de/legacy/legacycore.h
Expand Up @@ -23,6 +23,7 @@
#include "../libdeng2.h"
#include "../App"
#include "../Log"
#include "../String"

namespace de {

Expand Down Expand Up @@ -120,6 +121,15 @@ class DENG2_PUBLIC LegacyCore : public QObject
*/
const char* logFileName() const;

/**
* Begins a new section in the log. Sections can be nested.
*
* @param sectionName Name of the section. No copy of this string is made,
* so it must exist while the section is in use.
*/
void logAs(const char* sectionName);
void logAs(const String sectionName);

/**
* Prints a fragment of text to the output log. The output is added to the log
* only when a complete line has been printed (i.e., newline character required).
Expand Down
5 changes: 5 additions & 0 deletions doomsday/libdeng2/src/c_wrapper.cpp
Expand Up @@ -119,6 +119,11 @@ const char* LegacyCore_LogFile()
return DENG2_LEGACYCORE().logFileName();
}

void LegacyCore_LogAs(const char* sectionName)
{
DENG2_LEGACYCORE().logAs(sectionName);
}

void LegacyCore_PrintLogFragment(const char* text)
{
DENG2_LEGACYCORE().printLogFragment(text);
Expand Down
10 changes: 10 additions & 0 deletions doomsday/libdeng2/src/legacy/legacycore.cpp
Expand Up @@ -218,6 +218,16 @@ const char *LegacyCore::logFileName() const
return d->logName.c_str();
}

void LegacyCore::logAs(const char* sectionName)
{
LOG_AS(sectionName);
}

void LegacyCore::logAs(const String sectionName)
{
LOG_AS_STRING(sectionName);
}

void LegacyCore::printLogFragment(const char* text, Log::LogLevel level)
{
d->currentLogLine += text;
Expand Down

0 comments on commit 80b46cb

Please sign in to comment.