mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 21:49:55 +00:00
workaround OgreLog Unicode path handling
This commit is contained in:
parent
20527e0bd4
commit
444a07c01b
1 changed files with 47 additions and 0 deletions
|
@ -1,11 +1,15 @@
|
||||||
#include "ogreinit.hpp"
|
#include "ogreinit.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <ctime>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include <OgreRoot.h>
|
#include <OgreRoot.h>
|
||||||
#include <OgreParticleEmitterFactory.h>
|
#include <OgreParticleEmitterFactory.h>
|
||||||
#include <OgreParticleSystemManager.h>
|
#include <OgreParticleSystemManager.h>
|
||||||
#include <OgreLogManager.h>
|
#include <OgreLogManager.h>
|
||||||
|
#include <OgreLog.h>
|
||||||
|
|
||||||
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
||||||
#include <OSX/macUtils.h>
|
#include <OSX/macUtils.h>
|
||||||
|
@ -13,8 +17,47 @@
|
||||||
|
|
||||||
#include <components/nifogre/particles.hpp>
|
#include <components/nifogre/particles.hpp>
|
||||||
|
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
#include "ogreplugin.hpp"
|
#include "ogreplugin.hpp"
|
||||||
|
|
||||||
|
namespace bfs = boost::filesystem;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
class LogListener : public Ogre::LogListener
|
||||||
|
{
|
||||||
|
bfs::ofstream file;
|
||||||
|
char buffer[16];
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
LogListener(const std::string &path)
|
||||||
|
: file((bfs::path(path)))
|
||||||
|
{
|
||||||
|
memset(buffer, sizeof(buffer), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void timestamp()
|
||||||
|
{
|
||||||
|
int local = time(0) % 86400;
|
||||||
|
int sec = local % 60;
|
||||||
|
int min = (local / 60) % 60;
|
||||||
|
int hrs = local / 3600;
|
||||||
|
sprintf(buffer, "%02d:%02d:%02d: ", hrs, min, sec);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void messageLogged(const std::string &msg, Ogre::LogMessageLevel lvl, bool mask, const std::string &logName, bool &skip)
|
||||||
|
{
|
||||||
|
timestamp();
|
||||||
|
file << buffer << msg << std::endl;
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
namespace OgreInit
|
namespace OgreInit
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -43,6 +86,10 @@ namespace OgreInit
|
||||||
new Ogre::LogManager;
|
new Ogre::LogManager;
|
||||||
Ogre::Log *log = Ogre::LogManager::getSingleton().createLog(logPath);
|
Ogre::Log *log = Ogre::LogManager::getSingleton().createLog(logPath);
|
||||||
|
|
||||||
|
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
|
||||||
|
log->addListener(new LogListener(logPath));
|
||||||
|
#endif
|
||||||
|
|
||||||
// Disable logging to cout/cerr
|
// Disable logging to cout/cerr
|
||||||
log->setDebugOutputEnabled(false);
|
log->setDebugOutputEnabled(false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue