Implement Logger to replace raw cerr/cout and DPRINTF usage

pull/1251/head
Hleb Valoshka 2021-11-28 12:11:37 +02:00
parent b94d084af3
commit 14af83a391
112 changed files with 15295 additions and 15064 deletions

1008
po/ar.po

File diff suppressed because it is too large Load Diff

1148
po/be.po

File diff suppressed because it is too large Load Diff

1055
po/bg.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1010
po/de.po

File diff suppressed because it is too large Load Diff

1010
po/el.po

File diff suppressed because it is too large Load Diff

1010
po/es.po

File diff suppressed because it is too large Load Diff

1050
po/fr.po

File diff suppressed because it is too large Load Diff

1010
po/gl.po

File diff suppressed because it is too large Load Diff

1010
po/hu.po

File diff suppressed because it is too large Load Diff

1015
po/it.po

File diff suppressed because it is too large Load Diff

1016
po/ja.po

File diff suppressed because it is too large Load Diff

1010
po/ko.po

File diff suppressed because it is too large Load Diff

1027
po/lt.po

File diff suppressed because it is too large Load Diff

1010
po/lv.po

File diff suppressed because it is too large Load Diff

1010
po/nl.po

File diff suppressed because it is too large Load Diff

1010
po/no.po

File diff suppressed because it is too large Load Diff

1050
po/pl.po

File diff suppressed because it is too large Load Diff

1010
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1010
po/ro.po

File diff suppressed because it is too large Load Diff

1123
po/ru.po

File diff suppressed because it is too large Load Diff

1010
po/sk.po

File diff suppressed because it is too large Load Diff

1010
po/sv.po

File diff suppressed because it is too large Load Diff

1074
po/tr.po

File diff suppressed because it is too large Load Diff

1010
po/uk.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -16,13 +16,14 @@
#include <utility> #include <utility>
#include <Eigen/Core> #include <Eigen/Core>
#include <fmt/ostream.h>
#include <celutil/binaryread.h> #include <celutil/binaryread.h>
#include <celutil/logger.h>
#include "3dsmodel.h" #include "3dsmodel.h"
#include "3dsread.h" #include "3dsread.h"
namespace celutil = celestia::util; namespace celutil = celestia::util;
using celestia::util::GetLogger;
namespace namespace
{ {
@ -133,7 +134,8 @@ std::int32_t read3DSChunk(std::istream& in,
default: default:
if (processedSize != contentSize) if (processedSize != contentSize)
{ {
fmt::print(std::clog, "Chunk type {:04x}, expected {} bytes but read {}\n", chunkType, contentSize, processedSize); GetLogger()->error("Chunk type {:04x}, expected {} bytes but read {}\n",
static_cast<int>(chunkType), contentSize, processedSize);
return READ_FAILURE; return READ_FAILURE;
} }
return chunkSize; return chunkSize;
@ -153,7 +155,7 @@ std::int32_t read3DSChunks(std::istream& in,
{ {
std::int32_t chunkSize = read3DSChunk(in, chunkFunc, obj); std::int32_t chunkSize = read3DSChunk(in, chunkFunc, obj);
if (chunkSize < 0) { if (chunkSize < 0) {
fmt::print(std::clog, "Failed to read 3DS chunk\n"); GetLogger()->error("Failed to read 3DS chunk\n");
return READ_FAILURE; return READ_FAILURE;
} }
bytesRead += chunkSize; bytesRead += chunkSize;
@ -161,7 +163,7 @@ std::int32_t read3DSChunks(std::istream& in,
if (bytesRead != nBytes) if (bytesRead != nBytes)
{ {
fmt::print(std::clog, "Multiple chunks, expected {} bytes but read {}\n", nBytes, bytesRead); GetLogger()->error("Multiple chunks, expected {} bytes but read {}\n", nBytes, bytesRead);
return READ_FAILURE; return READ_FAILURE;
} }
@ -573,18 +575,18 @@ std::unique_ptr<M3DScene> Read3DSFile(std::istream& in)
M3DChunkType chunkType; M3DChunkType chunkType;
if (!readChunkType(in, chunkType) || chunkType != M3DChunkType::Magic) if (!readChunkType(in, chunkType) || chunkType != M3DChunkType::Magic)
{ {
fmt::print(std::clog, "Read3DSFile: Wrong magic number in header\n"); GetLogger()->error("Read3DSFile: Wrong magic number in header\n");
return nullptr; return nullptr;
} }
std::int32_t chunkSize; std::int32_t chunkSize;
if (!celutil::readLE<std::int32_t>(in, chunkSize) || chunkSize < 6) if (!celutil::readLE<std::int32_t>(in, chunkSize) || chunkSize < 6)
{ {
fmt::print(std::clog, "Read3DSFile: Error reading 3DS file top level chunk size\n"); GetLogger()->error("Read3DSFile: Error reading 3DS file top level chunk size\n");
return nullptr; return nullptr;
} }
fmt::print(std::clog, "3DS file, {} bytes\n", chunkSize + 6); GetLogger()->verbose("3DS file, {} bytes\n", chunkSize + 6);
auto scene = std::make_unique<M3DScene>(); auto scene = std::make_unique<M3DScene>();
std::int32_t contentSize = chunkSize - 6; std::int32_t contentSize = chunkSize - 6;
@ -605,7 +607,7 @@ std::unique_ptr<M3DScene> Read3DSFile(const fs::path& filename)
std::ifstream in(filename.string(), std::ios::in | std::ios::binary); std::ifstream in(filename.string(), std::ios::in | std::ios::binary);
if (!in.good()) if (!in.good())
{ {
fmt::print(std::clog, "Read3DSFile: Error opening {}\n", filename); GetLogger()->error("Read3DSFile: Error opening {}\n", filename);
return nullptr; return nullptr;
} }

View File

@ -8,7 +8,7 @@
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/tokenizer.h> #include <celutil/tokenizer.h>
#include "stardb.h" #include "stardb.h"
#include "asterism.h" #include "asterism.h"
@ -16,7 +16,7 @@
using namespace std; using namespace std;
using celestia::util::GetLogger;
Asterism::Asterism(string _name) : Asterism::Asterism(string _name) :
name(std::move(_name)) name(std::move(_name))
@ -115,7 +115,7 @@ AsterismList* ReadAsterismList(istream& in, const StarDatabase& stardb)
{ {
if (tokenizer.getTokenType() != Tokenizer::TokenString) if (tokenizer.getTokenType() != Tokenizer::TokenString)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error parsing asterism file.\n"); GetLogger()->error("Error parsing asterism file.\n");
for_each(asterisms->begin(), asterisms->end(), [](Asterism* ast) { delete ast; }); for_each(asterisms->begin(), asterisms->end(), [](Asterism* ast) { delete ast; });
delete asterisms; delete asterisms;
return nullptr; return nullptr;
@ -127,7 +127,7 @@ AsterismList* ReadAsterismList(istream& in, const StarDatabase& stardb)
Value* chainsValue = parser.readValue(); Value* chainsValue = parser.readValue();
if (chainsValue == nullptr || chainsValue->getType() != Value::ArrayType) if (chainsValue == nullptr || chainsValue->getType() != Value::ArrayType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error parsing asterism %s\n", name.c_str()); GetLogger()->error("Error parsing asterism {}\n", name);
for_each(asterisms->begin(), asterisms->end(), [](Asterism* ast) { delete ast; }); for_each(asterisms->begin(), asterisms->end(), [](Asterism* ast) { delete ast; });
delete ast; delete ast;
delete asterisms; delete asterisms;
@ -157,7 +157,7 @@ AsterismList* ReadAsterismList(istream& in, const StarDatabase& stardb)
if (star != nullptr) if (star != nullptr)
new_chain->push_back(star->getPosition()); new_chain->push_back(star->getPosition());
else else
DPRINTF(LOG_LEVEL_ERROR, "Error loading star \"%s\" for asterism \"%s\".\n", name.c_str(), i->getString().c_str()); GetLogger()->error("Error loading star \"{}\" for asterism \"{}\".\n", name, i->getString());
} }
} }

View File

@ -1,13 +1,14 @@
#include <celutil/logger.h>
#include <celutil/debug.h>
#include "parseobject.h" #include "parseobject.h"
#include "astroobj.h" #include "astroobj.h"
#include "category.h" #include "category.h"
using celestia::util::GetLogger;
void AstroObject::setIndex(AstroCatalog::IndexNumber nr) void AstroObject::setIndex(AstroCatalog::IndexNumber nr)
{ {
if (m_mainIndexNumber != AstroCatalog::InvalidIndex) if (m_mainIndexNumber != AstroCatalog::InvalidIndex)
DPRINTF(LOG_LEVEL_WARNING, "AstroObject::setIndex(%u) on object with already set index: %u!\n", nr, m_mainIndexNumber); GetLogger()->warn("AstroObject::setIndex({}) on object with already set index: {}!\n", nr, m_mainIndexNumber);
m_mainIndexNumber = nr; m_mainIndexNumber = nr;
} }

View File

@ -1,9 +1,11 @@
#include <iostream> #include <iostream>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celengine/astroobj.h> #include <celengine/astroobj.h>
#include "category.h" #include "category.h"
using celestia::util::GetLogger;
UserCategory::UserCategory(const std::string &n, UserCategory *p, const std::string &domain) : UserCategory::UserCategory(const std::string &n, UserCategory *p, const std::string &domain) :
m_name(n), m_name(n),
m_parent(p) m_parent(p)
@ -95,19 +97,19 @@ bool UserCategory::hasChild(const std::string &n) const
void UserCategory::cleanup() void UserCategory::cleanup()
{ {
DPRINTF(LOG_LEVEL_INFO, "UserCategory::cleanup()\n"); GetLogger()->debug("UserCategory::cleanup()\n Objects: {}\n Categories: {}\n",
DPRINTF(LOG_LEVEL_INFO, " Objects: %i\n", m_objlist.size()); m_objlist.size(), m_catlist.size());
DPRINTF(LOG_LEVEL_INFO, " Categories: %i\n", m_catlist.size());
while(!m_objlist.empty()) while(!m_objlist.empty())
{ {
auto it = m_objlist.begin(); auto it = m_objlist.begin();
DPRINTF(LOG_LEVEL_INFO, "Removing object: %s\n", it->getName()); GetLogger()->debug("Removing object: {}\n", it->getName());
removeObject(*it); removeObject(*it);
} }
while(!m_catlist.empty()) while(!m_catlist.empty())
{ {
auto it = m_catlist.begin(); auto it = m_catlist.begin();
DPRINTF(LOG_LEVEL_INFO, "Removing category: %s\n", (*it)->name()); GetLogger()->debug("Removing category: {}\n", (*it)->name());
deleteChild(*it); deleteChild(*it);
} }
} }
@ -137,7 +139,7 @@ UserCategory *UserCategory::find(const std::string &s)
{ {
if (m_allcats.count(s) == 0) if (m_allcats.count(s) == 0)
return nullptr; return nullptr;
DPRINTF(LOG_LEVEL_INFO, "UserCategory::find(%s): exists\n", s.c_str()); GetLogger()->info("UserCategory::find({}): exists\n", s.c_str());
return m_allcats.find(s)->second; return m_allcats.find(s)->second;
} }

View File

@ -19,7 +19,6 @@
#include "nebula.h" #include "nebula.h"
#include "opencluster.h" #include "opencluster.h"
#include <celengine/selection.h> #include <celengine/selection.h>
#include <celutil/debug.h>
#include <celmath/intersect.h> #include <celmath/intersect.h>
using namespace Eigen; using namespace Eigen;

View File

@ -17,21 +17,19 @@
#include <fmt/printf.h> #include <fmt/printf.h>
#include <celutil/debug.h>
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celutil/logger.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/bytes.h> #include <celutil/bytes.h>
#include <celutil/utf8.h> #include <celutil/utf8.h>
#include <celengine/dsodb.h> #include <celutil/tokenizer.h>
#include <config.h>
#include "astro.h" #include "astro.h"
#include "parser.h" #include "parser.h"
#include "parseobject.h" #include "parseobject.h"
#include "multitexture.h" #include "multitexture.h"
#include "meshmanager.h" #include "meshmanager.h"
#include <celutil/tokenizer.h>
#include <celutil/debug.h>
#include <celengine/dsodb.h>
#include <celengine/galaxy.h> #include <celengine/galaxy.h>
#include <celengine/globular.h> #include <celengine/globular.h>
#include <celengine/opencluster.h> #include <celengine/opencluster.h>
@ -42,7 +40,7 @@
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using celestia::util::GetLogger;
constexpr const float DSO_OCTREE_MAGNITUDE = 8.0f; constexpr const float DSO_OCTREE_MAGNITUDE = 8.0f;
//constexpr const float DSO_EXTRA_ROOM = 0.01f; // Reserve 1% capacity for extra DSOs //constexpr const float DSO_EXTRA_ROOM = 0.01f; // Reserve 1% capacity for extra DSOs
@ -241,7 +239,7 @@ bool DSODatabase::load(istream& in, const fs::path& resourcePath)
if (tokenizer.getTokenType() != Tokenizer::TokenName) if (tokenizer.getTokenType() != Tokenizer::TokenName)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error parsing deep sky catalog file.\n"); GetLogger()->error("Error parsing deep sky catalog file.\n");
return false; return false;
} }
objType = tokenizer.getNameValue(); objType = tokenizer.getNameValue();
@ -262,7 +260,7 @@ bool DSODatabase::load(istream& in, const fs::path& resourcePath)
if (tokenizer.nextToken() != Tokenizer::TokenString) if (tokenizer.nextToken() != Tokenizer::TokenString)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error parsing deep sky catalog file: bad name.\n"); GetLogger()->error("Error parsing deep sky catalog file: bad name.\n");
return false; return false;
} }
objName = tokenizer.getStringValue(); objName = tokenizer.getStringValue();
@ -271,7 +269,7 @@ bool DSODatabase::load(istream& in, const fs::path& resourcePath)
if (objParamsValue == nullptr || if (objParamsValue == nullptr ||
objParamsValue->getType() != Value::HashType) objParamsValue->getType() != Value::HashType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error parsing deep sky catalog entry %s\n", objName.c_str()); GetLogger()->error("Error parsing deep sky catalog entry {}\n", objName.c_str());
return false; return false;
} }
@ -347,7 +345,7 @@ bool DSODatabase::load(istream& in, const fs::path& resourcePath)
} }
else else
{ {
DPRINTF(LOG_LEVEL_WARNING, "Bad Deep Sky Object definition--will continue parsing file.\n"); GetLogger()->warn("Bad Deep Sky Object definition--will continue parsing file.\n");
delete objParamsValue; delete objParamsValue;
return false; return false;
} }
@ -376,13 +374,13 @@ void DSODatabase::finish()
DSOs[i]->setAbsoluteMagnitude((float)avgAbsMag); DSOs[i]->setAbsoluteMagnitude((float)avgAbsMag);
} }
*/ */
clog << fmt::sprintf(_("Loaded %i deep space objects\n"), nDSOs); GetLogger()->info(_("Loaded {} deep space objects\n"), nDSOs);
} }
void DSODatabase::buildOctree() void DSODatabase::buildOctree()
{ {
DPRINTF(LOG_LEVEL_INFO, "Sorting DSOs into octree . . .\n"); GetLogger()->debug("Sorting DSOs into octree . . .\n");
float absMag = astro::appToAbsMag(DSO_OCTREE_MAGNITUDE, DSO_OCTREE_ROOT_SIZE * (float) sqrt(3.0)); float absMag = astro::appToAbsMag(DSO_OCTREE_MAGNITUDE, DSO_OCTREE_ROOT_SIZE * (float) sqrt(3.0));
// TODO: investigate using a different center--it's possible that more // TODO: investigate using a different center--it's possible that more
@ -394,7 +392,7 @@ void DSODatabase::buildOctree()
root->insertObject(DSOs[i], DSO_OCTREE_ROOT_SIZE); root->insertObject(DSOs[i], DSO_OCTREE_ROOT_SIZE);
} }
DPRINTF(LOG_LEVEL_INFO, "Spatially sorting DSOs for improved locality of reference . . .\n"); GetLogger()->debug("Spatially sorting DSOs for improved locality of reference . . .\n");
DeepSkyObject** sortedDSOs = new DeepSkyObject*[nDSOs]; DeepSkyObject** sortedDSOs = new DeepSkyObject*[nDSOs];
DeepSkyObject** firstDSO = sortedDSOs; DeepSkyObject** firstDSO = sortedDSOs;
@ -402,11 +400,11 @@ void DSODatabase::buildOctree()
// are storing pointers to objects and not the objects themselves: // are storing pointers to objects and not the objects themselves:
root->rebuildAndSort(octreeRoot, firstDSO); root->rebuildAndSort(octreeRoot, firstDSO);
DPRINTF(LOG_LEVEL_INFO, "%d DSOs total\n", (int) (firstDSO - sortedDSOs)); GetLogger()->debug("{} DSOs total.\nOctree has {} nodes and {} DSOs.\n",
DPRINTF(LOG_LEVEL_INFO, "Octree has %d nodes and %d DSOs.\n", static_cast<int>(firstDSO - sortedDSOs),
1 + octreeRoot->countChildren(), octreeRoot->countObjects()); 1 + octreeRoot->countChildren(),
//cout<<"DSOs: "<< octreeRoot->countObjects()<<" Nodes:" octreeRoot->countObjects());
// <<octreeRoot->countChildren() <<endl;
// Clean up . . . // Clean up . . .
delete[] DSOs; delete[] DSOs;
delete root; delete root;
@ -439,7 +437,7 @@ void DSODatabase::buildIndexes()
// This should only be called once for the database // This should only be called once for the database
// assert(catalogNumberIndexes[0] == nullptr); // assert(catalogNumberIndexes[0] == nullptr);
DPRINTF(LOG_LEVEL_INFO, "Building catalog number indexes . . .\n"); GetLogger()->debug("Building catalog number indexes . . .\n");
catalogNumberIndex = new DeepSkyObject*[nDSOs]; catalogNumberIndex = new DeepSkyObject*[nDSOs];
for (int i = 0; i < nDSOs; ++i) for (int i = 0; i < nDSOs; ++i)

View File

@ -18,7 +18,6 @@
#include <celmath/ray.h> #include <celmath/ray.h>
#include <celmath/randutils.h> #include <celmath/randutils.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/debug.h>
#include <celcompat/filesystem.h> #include <celcompat/filesystem.h>
#include <fstream> #include <fstream>
#include <algorithm> #include <algorithm>

View File

@ -8,7 +8,6 @@
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <algorithm> #include <algorithm>
#include <celutil/debug.h>
#include "glcontext.h" #include "glcontext.h"
#include "glsupport.h" #include "glsupport.h"

View File

@ -19,7 +19,6 @@
#include <celmath/intersect.h> #include <celmath/intersect.h>
#include <celmath/ray.h> #include <celmath/ray.h>
#include <celmath/randutils.h> #include <celmath/randutils.h>
#include <celutil/debug.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include "astro.h" #include "astro.h"
#include "globular.h" #include "globular.h"

View File

@ -8,9 +8,11 @@
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <iostream> #include <iostream>
#include <celutil/logger.h>
#include "glshader.h" #include "glshader.h"
using namespace std; using namespace std;
using celestia::util::GetLogger;
static const string GetInfoLog(GLuint obj); static const string GetInfoLog(GLuint obj);
@ -392,7 +394,7 @@ GetInfoLog(GLuint obj)
} }
else else
{ {
cerr << "Unknown object passed to GetInfoLog()!\n"; GetLogger()->error("Unknown object passed to GetInfoLog()!\n");
return string(); return string();
} }

View File

@ -11,10 +11,8 @@
#include <cassert> #include <cassert>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <fmt/ostream.h>
#include <fmt/printf.h>
#include <celengine/glsupport.h> #include <celengine/glsupport.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/filetype.h> #include <celutil/filetype.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celimage/imageformats.h> #include <celimage/imageformats.h>
@ -22,6 +20,7 @@
using namespace std; using namespace std;
using celestia::PixelFormat; using celestia::PixelFormat;
using celestia::util::GetLogger;
namespace namespace
{ {
@ -288,7 +287,7 @@ Image* LoadImageFromFile(const fs::path& filename)
ContentType type = DetermineFileType(filename); ContentType type = DetermineFileType(filename);
Image* img = nullptr; Image* img = nullptr;
clog << fmt::sprintf(_("Loading image from file %s\n"), filename); GetLogger()->verbose(_("Loading image from file {}\n"), filename);
switch (type) switch (type)
{ {
@ -311,7 +310,7 @@ Image* LoadImageFromFile(const fs::path& filename)
img = LoadDDSImage(filename); img = LoadDDSImage(filename);
break; break;
default: default:
DPRINTF(LOG_LEVEL_ERROR, "%s: unrecognized or unsupported image file type.\n", filename); GetLogger()->error("{}: unrecognized or unsupported image file type.\n", filename);
break; break;
} }

View File

@ -12,12 +12,13 @@
#include <cmath> #include <cmath>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/fsutils.h> #include <celutil/fsutils.h>
#include "mapmanager.h" #include "mapmanager.h"
using namespace std; using namespace std;
using namespace celestia; using namespace celestia;
using celestia::util::GetLogger;
static std::array<const char*, 1> extensions = {"map"}; static std::array<const char*, 1> extensions = {"map"};
@ -147,25 +148,25 @@ WarpMesh* WarpMeshInfo::load(const fs::path& name)
int type, nx, ny; int type, nx, ny;
if (!(f >> type)) if (!(f >> type))
{ {
DPRINTF(LOG_LEVEL_ERROR, "Failed to read mesh header\n"); GetLogger()->error("Failed to read mesh header\n");
return nullptr; return nullptr;
} }
if (type != MESHTYPE_RECT) if (type != MESHTYPE_RECT)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Unsupported mesh type found: %d\n", type); GetLogger()->error("Unsupported mesh type found: {}\n", type);
return nullptr; return nullptr;
} }
if (!(f >> nx >> ny)) if (!(f >> nx >> ny))
{ {
DPRINTF(LOG_LEVEL_ERROR, "Failed to read mesh header\n"); GetLogger()->error("Failed to read mesh header\n");
return nullptr; return nullptr;
} }
if (nx < 2 || ny < 2) if (nx < 2 || ny < 2)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Row and column numbers should be larger than 2\n"); GetLogger()->error("Row and column numbers should be larger than 2\n");
return nullptr; return nullptr;
} }
@ -177,12 +178,12 @@ WarpMesh* WarpMeshInfo::load(const fs::path& name)
float *base = &data[(y * nx + x) * 5]; float *base = &data[(y * nx + x) * 5];
if (!(f >> base[0] >> base[1] >> base[2] >> base[3] >> base[4])) if (!(f >> base[0] >> base[1] >> base[2] >> base[3] >> base[4]))
{ {
DPRINTF(LOG_LEVEL_ERROR, "Failed to read mesh data\n"); GetLogger()->error("Failed to read mesh data\n");
delete[] data; delete[] data;
return nullptr; return nullptr;
} }
} }
} }
DPRINTF(LOG_LEVEL_INFO, "Read a mesh of %d * %d\n", nx, ny); GetLogger()->info("Read a mesh of {} x {}\n", nx, ny);
return new WarpMesh(nx, ny, data); return new WarpMesh(nx, ny, data);
} }

View File

@ -30,9 +30,9 @@
#include <celmodel/mesh.h> #include <celmodel/mesh.h>
#include <celmodel/model.h> #include <celmodel/model.h>
#include <celmodel/modelfile.h> #include <celmodel/modelfile.h>
#include <celutil/debug.h>
#include <celutil/filetype.h> #include <celutil/filetype.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/logger.h>
#include <celutil/tokenizer.h> #include <celutil/tokenizer.h>
#include "meshmanager.h" #include "meshmanager.h"
#include "modelgeometry.h" #include "modelgeometry.h"
@ -45,6 +45,8 @@
#include "particlesystemfile.h" #include "particlesystemfile.h"
#endif #endif
using celestia::util::GetLogger;
namespace namespace
{ {
@ -83,7 +85,7 @@ LoadCelestiaMesh(const fs::path& filename)
std::ifstream meshFile(filename.string(), std::ios::in); std::ifstream meshFile(filename.string(), std::ios::in);
if (!meshFile.good()) if (!meshFile.good())
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error opening mesh file: %s\n", filename); GetLogger()->error("Error opening mesh file: {}\n", filename);
return nullptr; return nullptr;
} }
@ -92,13 +94,13 @@ LoadCelestiaMesh(const fs::path& filename)
if (tokenizer.nextToken() != Tokenizer::TokenName) if (tokenizer.nextToken() != Tokenizer::TokenName)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Mesh file %s is invalid.\n", filename); GetLogger()->error("Mesh file {} is invalid.\n", filename);
return nullptr; return nullptr;
} }
if (tokenizer.getStringValue() != "SphereDisplacementMesh") if (tokenizer.getStringValue() != "SphereDisplacementMesh")
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: Unrecognized mesh type %s.\n", GetLogger()->error("{}: Unrecognized mesh type {}.\n",
filename, tokenizer.getStringValue()); filename, tokenizer.getStringValue());
return nullptr; return nullptr;
} }
@ -106,13 +108,13 @@ LoadCelestiaMesh(const fs::path& filename)
Value* meshDefValue = parser.readValue(); Value* meshDefValue = parser.readValue();
if (meshDefValue == nullptr) if (meshDefValue == nullptr)
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: Bad mesh file.\n", filename); GetLogger()->error("{}: Bad mesh file.\n", filename);
return nullptr; return nullptr;
} }
if (meshDefValue->getType() != Value::HashType) if (meshDefValue->getType() != Value::HashType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: Bad mesh file.\n", filename); GetLogger()->error("{}: Bad mesh file.\n", filename);
delete meshDefValue; delete meshDefValue;
return nullptr; return nullptr;
} }

View File

@ -9,7 +9,6 @@
#include "multitexture.h" #include "multitexture.h"
#include "texmanager.h" #include "texmanager.h"
#include <celutil/debug.h>
using namespace std; using namespace std;

View File

@ -1,4 +1,4 @@
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include "name.h" #include "name.h"
@ -14,7 +14,7 @@ void NameDatabase::add(const AstroCatalog::IndexNumber catalogNumber, const std:
#ifdef DEBUG #ifdef DEBUG
AstroCatalog::IndexNumber tmp; AstroCatalog::IndexNumber tmp;
if ((tmp = getCatalogNumberByName(name, false)) != AstroCatalog::InvalidIndex) if ((tmp = getCatalogNumberByName(name, false)) != AstroCatalog::InvalidIndex)
DPRINTF(LOG_LEVEL_INFO,"Duplicated name '%s' on object with catalog numbers: %d and %d\n", name.c_str(), tmp, catalogNumber); celestia::util::GetLogger()->debug("Duplicated name '{}' on object with catalog numbers: {} and {}\n", name, tmp, catalogNumber);
#endif #endif
// Add the new name // Add the new name
//nameIndex.insert(NameIndex::value_type(name, catalogNumber)); //nameIndex.insert(NameIndex::value_type(name, catalogNumber));

View File

@ -16,7 +16,6 @@
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <vector> #include <vector>
#include <celutil/debug.h>
#include <celutil/stringutils.h> #include <celutil/stringutils.h>
#include <celutil/utf8.h> #include <celutil/utf8.h>
#include <celengine/astroobj.h> #include <celengine/astroobj.h>

View File

@ -9,7 +9,6 @@
#include <algorithm> #include <algorithm>
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celutil/debug.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include "astro.h" #include "astro.h"
#include "meshmanager.h" #include "meshmanager.h"

View File

@ -13,7 +13,6 @@
#include "opencluster.h" #include "opencluster.h"
#include "meshmanager.h" #include "meshmanager.h"
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celutil/debug.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <algorithm> #include <algorithm>

View File

@ -13,7 +13,6 @@
#include <celmath/geomutil.h> #include <celmath/geomutil.h>
#include <celttf/truetypefont.h> #include <celttf/truetypefont.h>
#include <celutil/color.h> #include <celutil/color.h>
#include <celutil/debug.h>
#include <celutil/utf8.h> #include <celutil/utf8.h>
#include "overlay.h" #include "overlay.h"
#include "rectangle.h" #include "rectangle.h"

View File

@ -25,12 +25,13 @@
#include <celephem/scriptorbit.h> #include <celephem/scriptorbit.h>
#include <celephem/scriptrotation.h> #include <celephem/scriptrotation.h>
#include <celmath/geomutil.h> #include <celmath/geomutil.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <cassert> #include <cassert>
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using namespace celmath; using namespace celmath;
using celestia::util::GetLogger;
/** /**
* Returns the default units scale for orbits. * Returns the default units scale for orbits.
@ -150,7 +151,7 @@ CreateEllipticalOrbit(Hash* orbitData,
{ {
if (!orbitData->getLength("PericenterDistance", pericenterDistance, 1.0, distanceScale)) if (!orbitData->getLength("PericenterDistance", pericenterDistance, 1.0, distanceScale))
{ {
clog << "SemiMajorAxis/PericenterDistance missing! Skipping planet . . .\n"; GetLogger()->error("SemiMajorAxis/PericenterDistance missing! Skipping planet . . .\n");
return nullptr; return nullptr;
} }
} }
@ -158,7 +159,7 @@ CreateEllipticalOrbit(Hash* orbitData,
double period = 0.0; double period = 0.0;
if (!orbitData->getTime("Period", period, 1.0, timeScale)) if (!orbitData->getTime("Period", period, 1.0, timeScale))
{ {
clog << "Period missing! Skipping planet . . .\n"; GetLogger()->error("Period missing! Skipping planet . . .\n");
return nullptr; return nullptr;
} }
@ -231,7 +232,7 @@ CreateSampledTrajectory(Hash* trajData, const fs::path& path)
string sourceName; string sourceName;
if (!trajData->getString("Source", sourceName)) if (!trajData->getString("Source", sourceName))
{ {
clog << "SampledTrajectory is missing a source.\n"; GetLogger()->error("SampledTrajectory is missing a source.\n");
return nullptr; return nullptr;
} }
@ -246,7 +247,7 @@ CreateSampledTrajectory(Hash* trajData, const fs::path& path)
else if (!compareIgnoringCase(interpolationString, "cubic")) else if (!compareIgnoringCase(interpolationString, "cubic"))
interpolation = TrajectoryInterpolationCubic; interpolation = TrajectoryInterpolationCubic;
else else
clog << "Unknown interpolation type " << interpolationString << endl; // non-fatal error GetLogger()->warn("Unknown interpolation type {}\n", interpolationString); // non-fatal error
} }
// Double precision is true by default // Double precision is true by default
@ -254,12 +255,12 @@ CreateSampledTrajectory(Hash* trajData, const fs::path& path)
trajData->getBoolean("DoublePrecision", useDoublePrecision); trajData->getBoolean("DoublePrecision", useDoublePrecision);
TrajectoryPrecision precision = useDoublePrecision ? TrajectoryPrecisionDouble : TrajectoryPrecisionSingle; TrajectoryPrecision precision = useDoublePrecision ? TrajectoryPrecisionDouble : TrajectoryPrecisionSingle;
DPRINTF(LOG_LEVEL_INFO, "Attempting to load sampled trajectory from source '%s'\n", sourceName.c_str()); GetLogger()->verbose("Attempting to load sampled trajectory from source '{}'\n", sourceName);
ResourceHandle orbitHandle = GetTrajectoryManager()->getHandle(TrajectoryInfo(sourceName, path, interpolation, precision)); ResourceHandle orbitHandle = GetTrajectoryManager()->getHandle(TrajectoryInfo(sourceName, path, interpolation, precision));
Orbit* orbit = GetTrajectoryManager()->find(orbitHandle); Orbit* orbit = GetTrajectoryManager()->find(orbitHandle);
if (orbit == nullptr) if (orbit == nullptr)
{ {
clog << "Could not load sampled trajectory from '" << sourceName << "'\n"; GetLogger()->error("Could not load sampled trajectory from '{}'\n", sourceName);
} }
return orbit; return orbit;
@ -297,7 +298,7 @@ CreateFixedPosition(Hash* trajData, const Selection& centralObject, bool usePlan
{ {
if (centralObject.getType() != Selection::Type_Body) if (centralObject.getType() != Selection::Type_Body)
{ {
clog << "FixedPosition planetographic coordinates aren't valid for stars.\n"; GetLogger()->error("FixedPosition planetographic coordinates aren't valid for stars.\n");
return nullptr; return nullptr;
} }
@ -309,7 +310,7 @@ CreateFixedPosition(Hash* trajData, const Selection& centralObject, bool usePlan
{ {
if (centralObject.getType() != Selection::Type_Body) if (centralObject.getType() != Selection::Type_Body)
{ {
clog << "FixedPosition planetocentric coordinates aren't valid for stars.\n"; GetLogger()->error("FixedPosition planetocentric coordinates aren't valid for stars.\n");
return nullptr; return nullptr;
} }
@ -318,7 +319,7 @@ CreateFixedPosition(Hash* trajData, const Selection& centralObject, bool usePlan
} }
else else
{ {
clog << "Missing coordinates for FixedPosition\n"; GetLogger()->error("Missing coordinates for FixedPosition\n");
return nullptr; return nullptr;
} }
@ -418,20 +419,20 @@ CreateSpiceOrbit(Hash* orbitData,
// the kernel pool. // the kernel pool.
if (!ParseStringList(orbitData, "Kernel", kernelList)) if (!ParseStringList(orbitData, "Kernel", kernelList))
{ {
clog << "Kernel list for SPICE orbit is neither a string nor array of strings\n"; GetLogger()->error("Kernel list for SPICE orbit is neither a string nor array of strings\n");
return nullptr; return nullptr;
} }
} }
if (!orbitData->getString("Target", targetBodyName)) if (!orbitData->getString("Target", targetBodyName))
{ {
clog << "Target name missing from SPICE orbit\n"; GetLogger()->error("Target name missing from SPICE orbit\n");
return nullptr; return nullptr;
} }
if (!orbitData->getString("Origin", originName)) if (!orbitData->getString("Origin", originName))
{ {
clog << "Origin name missing from SPICE orbit\n"; GetLogger()->error("Origin name missing from SPICE orbit\n");
return nullptr; return nullptr;
} }
@ -439,7 +440,7 @@ CreateSpiceOrbit(Hash* orbitData,
double boundingRadius = 0.0; double boundingRadius = 0.0;
if (!orbitData->getLength("BoundingRadius", boundingRadius, 1.0, distanceScale)) if (!orbitData->getLength("BoundingRadius", boundingRadius, 1.0, distanceScale))
{ {
clog << "Bounding Radius missing from SPICE orbit\n"; GetLogger()->error("Bounding Radius missing from SPICE orbit\n");
return nullptr; return nullptr;
} }
@ -455,13 +456,13 @@ CreateSpiceOrbit(Hash* orbitData,
Value* endingDate = orbitData->getValue("Ending"); Value* endingDate = orbitData->getValue("Ending");
if (beginningDate != nullptr && endingDate == nullptr) if (beginningDate != nullptr && endingDate == nullptr)
{ {
clog << "Beginning specified for SPICE orbit, but ending is missing.\n"; GetLogger()->error("Beginning specified for SPICE orbit, but ending is missing.\n");
return nullptr; return nullptr;
} }
if (endingDate != nullptr && beginningDate == nullptr) if (endingDate != nullptr && beginningDate == nullptr)
{ {
clog << "Ending specified for SPICE orbit, but beginning is missing.\n"; GetLogger()->error("Ending specified for SPICE orbit, but beginning is missing.\n");
return nullptr; return nullptr;
} }
@ -471,14 +472,14 @@ CreateSpiceOrbit(Hash* orbitData,
double beginningTDBJD = 0.0; double beginningTDBJD = 0.0;
if (!ParseDate(orbitData, "Beginning", beginningTDBJD)) if (!ParseDate(orbitData, "Beginning", beginningTDBJD))
{ {
clog << "Invalid beginning date specified for SPICE orbit.\n"; GetLogger()->error("Invalid beginning date specified for SPICE orbit.\n");
return nullptr; return nullptr;
} }
double endingTDBJD = 0.0; double endingTDBJD = 0.0;
if (!ParseDate(orbitData, "Ending", endingTDBJD)) if (!ParseDate(orbitData, "Ending", endingTDBJD))
{ {
clog << "Invalid ending date specified for SPICE orbit.\n"; GetLogger()->error("Invalid ending date specified for SPICE orbit.\n");
return nullptr; return nullptr;
} }
@ -553,14 +554,14 @@ CreateSpiceRotation(Hash* rotationData,
// the kernel pool. // the kernel pool.
if (!ParseStringList(rotationData, "Kernel", kernelList)) if (!ParseStringList(rotationData, "Kernel", kernelList))
{ {
clog << "Kernel list for SPICE rotation is neither a string nor array of strings\n"; GetLogger()->warn("Kernel list for SPICE rotation is neither a string nor array of strings\n");
return nullptr; return nullptr;
} }
} }
if (!rotationData->getString("Frame", frameName)) if (!rotationData->getString("Frame", frameName))
{ {
clog << "Frame name missing from SPICE rotation\n"; GetLogger()->error("Frame name missing from SPICE rotation\n");
return nullptr; return nullptr;
} }
@ -578,13 +579,13 @@ CreateSpiceRotation(Hash* rotationData,
Value* endingDate = rotationData->getValue("Ending"); Value* endingDate = rotationData->getValue("Ending");
if (beginningDate != nullptr && endingDate == nullptr) if (beginningDate != nullptr && endingDate == nullptr)
{ {
clog << "Beginning specified for SPICE rotation, but ending is missing.\n"; GetLogger()->error("Beginning specified for SPICE rotation, but ending is missing.\n");
return nullptr; return nullptr;
} }
if (endingDate != nullptr && beginningDate == nullptr) if (endingDate != nullptr && beginningDate == nullptr)
{ {
clog << "Ending specified for SPICE rotation, but beginning is missing.\n"; GetLogger()->error("Ending specified for SPICE rotation, but beginning is missing.\n");
return nullptr; return nullptr;
} }
@ -594,14 +595,14 @@ CreateSpiceRotation(Hash* rotationData,
double beginningTDBJD = 0.0; double beginningTDBJD = 0.0;
if (!ParseDate(rotationData, "Beginning", beginningTDBJD)) if (!ParseDate(rotationData, "Beginning", beginningTDBJD))
{ {
clog << "Invalid beginning date specified for SPICE rotation.\n"; GetLogger()->error("Invalid beginning date specified for SPICE rotation.\n");
return nullptr; return nullptr;
} }
double endingTDBJD = 0.0; double endingTDBJD = 0.0;
if (!ParseDate(rotationData, "Ending", endingTDBJD)) if (!ParseDate(rotationData, "Ending", endingTDBJD))
{ {
clog << "Invalid ending date specified for SPICE rotation.\n"; GetLogger()->error("Invalid ending date specified for SPICE rotation.\n");
return nullptr; return nullptr;
} }
@ -636,7 +637,7 @@ CreateScriptedOrbit(Hash* orbitData,
const fs::path& path) const fs::path& path)
{ {
#if !defined(CELX) #if !defined(CELX)
clog << "ScriptedOrbit not usable without scripting support.\n"; GetLogger()->warn("ScriptedOrbit not usable without scripting support.\n");
return nullptr; return nullptr;
#else #else
@ -644,7 +645,7 @@ CreateScriptedOrbit(Hash* orbitData,
string funcName; string funcName;
if (!orbitData->getString("Function", funcName)) if (!orbitData->getString("Function", funcName))
{ {
clog << "Function name missing from script orbit definition.\n"; GetLogger()->error("Function name missing from script orbit definition.\n");
return nullptr; return nullptr;
} }
@ -683,8 +684,7 @@ CreateOrbit(const Selection& centralObject,
{ {
return orbit; return orbit;
} }
clog << "Could not find custom orbit named '" << customOrbitName << GetLogger()->error("Could not find custom orbit named '{}'\n", customOrbitName);
"'\n";
} }
#ifdef USE_SPICE #ifdef USE_SPICE
@ -693,7 +693,7 @@ CreateOrbit(const Selection& centralObject,
{ {
if (spiceOrbitDataValue->getType() != Value::HashType) if (spiceOrbitDataValue->getType() != Value::HashType)
{ {
clog << "Object has incorrect spice orbit syntax.\n"; GetLogger()->error("Object has incorrect spice orbit syntax.\n");
return nullptr; return nullptr;
} }
else else
@ -703,8 +703,8 @@ CreateOrbit(const Selection& centralObject,
{ {
return orbit; return orbit;
} }
clog << "Bad spice orbit\n"; GetLogger()->error("Bad spice orbit\n");
DPRINTF(LOG_LEVEL_ERROR, "Could not load SPICE orbit\n"); GetLogger()->error("Could not load SPICE orbit\n");
} }
} }
#endif #endif
@ -715,7 +715,7 @@ CreateOrbit(const Selection& centralObject,
{ {
if (scriptedOrbitValue->getType() != Value::HashType) if (scriptedOrbitValue->getType() != Value::HashType)
{ {
clog << "Object has incorrect scripted orbit syntax.\n"; GetLogger()->error("Object has incorrect scripted orbit syntax.\n");
return nullptr; return nullptr;
} }
@ -731,7 +731,7 @@ CreateOrbit(const Selection& centralObject,
{ {
if (sampledTrajDataValue->getType() != Value::HashType) if (sampledTrajDataValue->getType() != Value::HashType)
{ {
clog << "Object has incorrect syntax for SampledTrajectory.\n"; GetLogger()->error("Object has incorrect syntax for SampledTrajectory.\n");
return nullptr; return nullptr;
} }
@ -743,8 +743,7 @@ CreateOrbit(const Selection& centralObject,
string sampOrbitFile; string sampOrbitFile;
if (planetData->getString("SampledOrbit", sampOrbitFile)) if (planetData->getString("SampledOrbit", sampOrbitFile))
{ {
DPRINTF(LOG_LEVEL_INFO, "Attempting to load sampled orbit file '%s'\n", GetLogger()->verbose("Attempting to load sampled orbit file '{}'\n", sampOrbitFile);
sampOrbitFile.c_str());
ResourceHandle orbitHandle = ResourceHandle orbitHandle =
GetTrajectoryManager()->getHandle(TrajectoryInfo(sampOrbitFile, GetTrajectoryManager()->getHandle(TrajectoryInfo(sampOrbitFile,
path, path,
@ -755,7 +754,7 @@ CreateOrbit(const Selection& centralObject,
{ {
return orbit; return orbit;
} }
clog << "Could not load sampled orbit file '" << sampOrbitFile << "'\n"; GetLogger()->error("Could not load sampled orbit file '{}'\n", sampOrbitFile);
} }
Value* orbitDataValue = planetData->getValue("EllipticalOrbit"); Value* orbitDataValue = planetData->getValue("EllipticalOrbit");
@ -763,7 +762,7 @@ CreateOrbit(const Selection& centralObject,
{ {
if (orbitDataValue->getType() != Value::HashType) if (orbitDataValue->getType() != Value::HashType)
{ {
clog << "Object has incorrect elliptical orbit syntax.\n"; GetLogger()->error("Object has incorrect elliptical orbit syntax.\n");
return nullptr; return nullptr;
} }
@ -805,7 +804,7 @@ CreateOrbit(const Selection& centralObject,
return CreateFixedPosition(fixedPositionValue->getHash(), centralObject, usePlanetUnits); return CreateFixedPosition(fixedPositionValue->getHash(), centralObject, usePlanetUnits);
} }
clog << "Object has incorrect FixedPosition syntax.\n"; GetLogger()->error("Object has incorrect FixedPosition syntax.\n");
} }
// LongLat will make an object fixed relative to the surface of its center // LongLat will make an object fixed relative to the surface of its center
@ -1007,7 +1006,7 @@ CreateScriptedRotation(Hash* rotationData,
const fs::path& path) const fs::path& path)
{ {
#if !defined(CELX) #if !defined(CELX)
clog << "ScriptedRotation not usable without scripting support.\n"; GetLogger()->warn("ScriptedRotation not usable without scripting support.\n");
return nullptr; return nullptr;
#else #else
@ -1015,7 +1014,7 @@ CreateScriptedRotation(Hash* rotationData,
string funcName; string funcName;
if (!rotationData->getString("Function", funcName)) if (!rotationData->getString("Function", funcName))
{ {
clog << "Function name missing from scripted rotation definition.\n"; GetLogger()->error("Function name missing from scripted rotation definition.\n");
return nullptr; return nullptr;
} }
@ -1068,8 +1067,8 @@ CreateRotationModel(Hash* planetData,
{ {
return rotationModel; return rotationModel;
} }
clog << "Could not find custom rotation model named '" << GetLogger()->error("Could not find custom rotation model named '{}'\n",
customRotationModelName << "'\n"; customRotationModelName);
} }
#ifdef USE_SPICE #ifdef USE_SPICE
@ -1078,7 +1077,7 @@ CreateRotationModel(Hash* planetData,
{ {
if (spiceRotationDataValue->getType() != Value::HashType) if (spiceRotationDataValue->getType() != Value::HashType)
{ {
clog << "Object has incorrect spice rotation syntax.\n"; GetLogger()->error("Object has incorrect spice rotation syntax.\n");
return nullptr; return nullptr;
} }
else else
@ -1088,8 +1087,7 @@ CreateRotationModel(Hash* planetData,
{ {
return rotationModel; return rotationModel;
} }
clog << "Bad spice rotation model\n"; GetLogger()->error("Bad spice rotation model\nCould not load SPICE rotation model\n");
DPRINTF(LOG_LEVEL_ERROR, "Could not load SPICE rotation model\n");
} }
} }
#endif #endif
@ -1099,7 +1097,7 @@ CreateRotationModel(Hash* planetData,
{ {
if (scriptedRotationValue->getType() != Value::HashType) if (scriptedRotationValue->getType() != Value::HashType)
{ {
clog << "Object has incorrect scripted rotation syntax.\n"; GetLogger()->error("Object has incorrect scripted rotation syntax.\n");
return nullptr; return nullptr;
} }
@ -1112,8 +1110,7 @@ CreateRotationModel(Hash* planetData,
string sampOrientationFile; string sampOrientationFile;
if (planetData->getString("SampledOrientation", sampOrientationFile)) if (planetData->getString("SampledOrientation", sampOrientationFile))
{ {
DPRINTF(LOG_LEVEL_INFO, "Attempting to load orientation file '%s'\n", GetLogger()->verbose("Attempting to load orientation file '{}'\n", sampOrientationFile);
sampOrientationFile.c_str());
ResourceHandle orientationHandle = ResourceHandle orientationHandle =
GetRotationModelManager()->getHandle(RotationModelInfo(sampOrientationFile, path)); GetRotationModelManager()->getHandle(RotationModelInfo(sampOrientationFile, path));
rotationModel = GetRotationModelManager()->find(orientationHandle); rotationModel = GetRotationModelManager()->find(orientationHandle);
@ -1122,8 +1119,7 @@ CreateRotationModel(Hash* planetData,
return rotationModel; return rotationModel;
} }
clog << "Could not load rotation model file '" << GetLogger()->error("Could not load rotation model file '{}'\n", sampOrientationFile);
sampOrientationFile << "'\n";
} }
Value* precessingRotationValue = planetData->getValue("PrecessingRotation"); Value* precessingRotationValue = planetData->getValue("PrecessingRotation");
@ -1131,7 +1127,7 @@ CreateRotationModel(Hash* planetData,
{ {
if (precessingRotationValue->getType() != Value::HashType) if (precessingRotationValue->getType() != Value::HashType)
{ {
clog << "Object has incorrect syntax for precessing rotation.\n"; GetLogger()->error("Object has incorrect syntax for precessing rotation.\n");
return nullptr; return nullptr;
} }
@ -1144,7 +1140,7 @@ CreateRotationModel(Hash* planetData,
{ {
if (uniformRotationValue->getType() != Value::HashType) if (uniformRotationValue->getType() != Value::HashType)
{ {
clog << "Object has incorrect UniformRotation syntax.\n"; GetLogger()->error("Object has incorrect UniformRotation syntax.\n");
return nullptr; return nullptr;
} }
return CreateUniformRotationModel(uniformRotationValue->getHash(), return CreateUniformRotationModel(uniformRotationValue->getHash(),
@ -1156,7 +1152,7 @@ CreateRotationModel(Hash* planetData,
{ {
if (fixedRotationValue->getType() != Value::HashType) if (fixedRotationValue->getType() != Value::HashType)
{ {
clog << "Object has incorrect FixedRotation syntax.\n"; GetLogger()->error("Object has incorrect FixedRotation syntax.\n");
return nullptr; return nullptr;
} }
@ -1168,7 +1164,7 @@ CreateRotationModel(Hash* planetData,
{ {
if (fixedAttitudeValue->getType() != Value::HashType) if (fixedAttitudeValue->getType() != Value::HashType)
{ {
clog << "Object has incorrect FixedAttitude syntax.\n"; GetLogger()->error("Object has incorrect FixedAttitude syntax.\n");
return nullptr; return nullptr;
} }
@ -1288,14 +1284,14 @@ getFrameCenter(const Universe& universe, Hash* frameData, const Selection& defau
if (!frameData->getString("Center", centerName)) if (!frameData->getString("Center", centerName))
{ {
if (defaultCenter.empty()) if (defaultCenter.empty())
cerr << "No center specified for reference frame.\n"; GetLogger()->warn("No center specified for reference frame.\n");
return defaultCenter; return defaultCenter;
} }
Selection centerObject = universe.findPath(centerName, nullptr, 0); Selection centerObject = universe.findPath(centerName, nullptr, 0);
if (centerObject.empty()) if (centerObject.empty())
{ {
cerr << "Center object '" << centerName << "' of reference frame not found.\n"; GetLogger()->error("Center object '{}' of reference frame not found.\n", centerName);
return Selection(); return Selection();
} }
@ -1336,12 +1332,12 @@ CreateMeanEquatorFrame(const Universe& universe,
obj = universe.findPath(objName, nullptr, 0); obj = universe.findPath(objName, nullptr, 0);
if (obj.empty()) if (obj.empty())
{ {
clog << "Object '" << objName << "' for mean equator frame not found.\n"; GetLogger()->error("Object '{}' for mean equator frame not found.\n", objName);
return nullptr; return nullptr;
} }
} }
clog << "CreateMeanEquatorFrame " << center.getName() << ", " << obj.getName() << "\n"; GetLogger()->debug("CreateMeanEquatorFrame {}, {}\n", center.getName(), obj.getName());
double freezeEpoch = 0.0; double freezeEpoch = 0.0;
BodyMeanEquatorFrame *ptr; BodyMeanEquatorFrame *ptr;
@ -1408,14 +1404,14 @@ getAxis(Hash* vectorData)
string axisLabel; string axisLabel;
if (!vectorData->getString("Axis", axisLabel)) if (!vectorData->getString("Axis", axisLabel))
{ {
DPRINTF(LOG_LEVEL_ERROR, "Bad two-vector frame: missing axis label for vector.\n"); GetLogger()->error("Bad two-vector frame: missing axis label for vector.\n");
return 0; return 0;
} }
int axis = parseAxisLabel(axisLabel); int axis = parseAxisLabel(axisLabel);
if (axis == 0) if (axis == 0)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Bad two-vector frame: vector has invalid axis label.\n"); GetLogger()->error("Bad two-vector frame: vector has invalid axis label.\n");
} }
// Permute axis labels to match non-standard Celestia coordinate // Permute axis labels to match non-standard Celestia coordinate
@ -1448,14 +1444,15 @@ getVectorTarget(const Universe& universe, Hash* vectorData)
string targetName; string targetName;
if (!vectorData->getString("Target", targetName)) if (!vectorData->getString("Target", targetName))
{ {
clog << "Bad two-vector frame: no target specified for vector.\n"; GetLogger()->warn("Bad two-vector frame: no target specified for vector.\n");
return Selection(); return Selection();
} }
Selection targetObject = universe.findPath(targetName, nullptr, 0); Selection targetObject = universe.findPath(targetName, nullptr, 0);
if (targetObject.empty()) if (targetObject.empty())
{ {
clog << "Bad two-vector frame: target object '" << targetName << "' of vector not found.\n"; GetLogger()->warn("Bad two-vector frame: target object '{}' of vector not found.\n",
targetName);
return Selection(); return Selection();
} }
@ -1481,7 +1478,8 @@ getVectorObserver(const Universe& universe, Hash* vectorData)
Selection obsObject = universe.findPath(obsName, nullptr, 0); Selection obsObject = universe.findPath(obsName, nullptr, 0);
if (obsObject.empty()) if (obsObject.empty())
{ {
clog << "Bad two-vector frame: observer object '" << obsObject.getName() << "' of vector not found.\n"; GetLogger()->warn("Bad two-vector frame: observer object '{}' of vector not found.\n",
obsObject.getName());
return Selection(); return Selection();
} }
@ -1536,7 +1534,7 @@ CreateFrameVector(const Universe& universe,
constVecData->getVector("Vector", vec); constVecData->getVector("Vector", vec);
if (vec.norm() == 0.0) if (vec.norm() == 0.0)
{ {
clog << "Bad two-vector frame: constant vector has length zero\n"; GetLogger()->error("Bad two-vector frame: constant vector has length zero\n");
return nullptr; return nullptr;
} }
vec.normalize(); vec.normalize();
@ -1557,7 +1555,7 @@ CreateFrameVector(const Universe& universe,
} }
else else
{ {
clog << "Bad two-vector frame: unknown vector type\n"; GetLogger()->error("Bad two-vector frame: unknown vector type\n");
return nullptr; return nullptr;
} }
} }
@ -1576,28 +1574,28 @@ CreateTwoVectorFrame(const Universe& universe,
Value* primaryValue = frameData->getValue("Primary"); Value* primaryValue = frameData->getValue("Primary");
if (primaryValue == nullptr) if (primaryValue == nullptr)
{ {
clog << "Primary axis missing from two-vector frame.\n"; GetLogger()->error("Primary axis missing from two-vector frame.\n");
return nullptr; return nullptr;
} }
Hash* primaryData = primaryValue->getHash(); Hash* primaryData = primaryValue->getHash();
if (primaryData == nullptr) if (primaryData == nullptr)
{ {
clog << "Bad syntax for primary axis of two-vector frame.\n"; GetLogger()->error("Bad syntax for primary axis of two-vector frame.\n");
return nullptr; return nullptr;
} }
Value* secondaryValue = frameData->getValue("Secondary"); Value* secondaryValue = frameData->getValue("Secondary");
if (secondaryValue == nullptr) if (secondaryValue == nullptr)
{ {
clog << "Secondary axis missing from two-vector frame.\n"; GetLogger()->error("Secondary axis missing from two-vector frame.\n");
return nullptr; return nullptr;
} }
Hash* secondaryData = secondaryValue->getHash(); Hash* secondaryData = secondaryValue->getHash();
if (secondaryData == nullptr) if (secondaryData == nullptr)
{ {
clog << "Bad syntax for secondary axis of two-vector frame.\n"; GetLogger()->error("Bad syntax for secondary axis of two-vector frame.\n");
return nullptr; return nullptr;
} }
@ -1614,7 +1612,7 @@ CreateTwoVectorFrame(const Universe& universe,
if (abs(primaryAxis) == abs(secondaryAxis)) if (abs(primaryAxis) == abs(secondaryAxis))
{ {
clog << "Bad two-vector frame: axes for vectors are collinear.\n"; GetLogger()->error("Bad two-vector frame: axes for vectors are collinear.\n");
return nullptr; return nullptr;
} }
@ -1741,7 +1739,7 @@ CreateTopocentricFrame(const Universe& universe,
center = universe.findPath(centerName, nullptr, 0); center = universe.findPath(centerName, nullptr, 0);
if (center.empty()) if (center.empty())
{ {
cerr << "Center object '" << centerName << "' for topocentric frame not found.\n"; GetLogger()->error("Center object '{}' for topocentric frame not found.\n", centerName);
return nullptr; return nullptr;
} }
@ -1763,7 +1761,7 @@ CreateTopocentricFrame(const Universe& universe,
{ {
if (target.empty()) if (target.empty())
{ {
cerr << "No target specified for topocentric frame.\n"; GetLogger()->error("No target specified for topocentric frame.\n");
return nullptr; return nullptr;
} }
} }
@ -1772,7 +1770,7 @@ CreateTopocentricFrame(const Universe& universe,
target = universe.findPath(targetName, nullptr, 0); target = universe.findPath(targetName, nullptr, 0);
if (target.empty()) if (target.empty())
{ {
cerr << "Target object '" << targetName << "' for topocentric frame not found.\n"; GetLogger()->error("Target object '{}' for topocentric frame not found.\n", targetName);
return nullptr; return nullptr;
} }
@ -1786,7 +1784,7 @@ CreateTopocentricFrame(const Universe& universe,
{ {
if (observer.empty()) if (observer.empty())
{ {
cerr << "No observer specified for topocentric frame.\n"; GetLogger()->error("No observer specified for topocentric frame.\n");
return nullptr; return nullptr;
} }
} }
@ -1795,7 +1793,7 @@ CreateTopocentricFrame(const Universe& universe,
observer = universe.findPath(observerName, nullptr, 0); observer = universe.findPath(observerName, nullptr, 0);
if (observer.empty()) if (observer.empty())
{ {
cerr << "Observer object '" << observerName << "' for topocentric frame not found.\n"; GetLogger()->error("Observer object '{}' for topocentric frame not found.\n", observerName);
return nullptr; return nullptr;
} }
} }
@ -1812,7 +1810,7 @@ CreateComplexFrame(const Universe& universe, Hash* frameData, const Selection& d
{ {
if (value->getType() != Value::HashType) if (value->getType() != Value::HashType)
{ {
clog << "Object has incorrect body-fixed frame syntax.\n"; GetLogger()->error("Object has incorrect body-fixed frame syntax.\n");
return nullptr; return nullptr;
} }
@ -1824,7 +1822,7 @@ CreateComplexFrame(const Universe& universe, Hash* frameData, const Selection& d
{ {
if (value->getType() != Value::HashType) if (value->getType() != Value::HashType)
{ {
clog << "Object has incorrect mean equator frame syntax.\n"; GetLogger()->error("Object has incorrect mean equator frame syntax.\n");
return nullptr; return nullptr;
} }
@ -1836,7 +1834,7 @@ CreateComplexFrame(const Universe& universe, Hash* frameData, const Selection& d
{ {
if (value->getType() != Value::HashType) if (value->getType() != Value::HashType)
{ {
clog << "Object has incorrect two-vector frame syntax.\n"; GetLogger()->error("Object has incorrect two-vector frame syntax.\n");
return nullptr; return nullptr;
} }
@ -1848,7 +1846,7 @@ CreateComplexFrame(const Universe& universe, Hash* frameData, const Selection& d
{ {
if (value->getType() != Value::HashType) if (value->getType() != Value::HashType)
{ {
clog << "Object has incorrect topocentric frame syntax.\n"; GetLogger()->error("Object has incorrect topocentric frame syntax.\n");
return nullptr; return nullptr;
} }
@ -1860,7 +1858,7 @@ CreateComplexFrame(const Universe& universe, Hash* frameData, const Selection& d
{ {
if (value->getType() != Value::HashType) if (value->getType() != Value::HashType)
{ {
clog << "Object has incorrect J2000 ecliptic frame syntax.\n"; GetLogger()->error("Object has incorrect J2000 ecliptic frame syntax.\n");
return nullptr; return nullptr;
} }
@ -1872,14 +1870,14 @@ CreateComplexFrame(const Universe& universe, Hash* frameData, const Selection& d
{ {
if (value->getType() != Value::HashType) if (value->getType() != Value::HashType)
{ {
clog << "Object has incorrect J2000 equator frame syntax.\n"; GetLogger()->error("Object has incorrect J2000 equator frame syntax.\n");
return nullptr; return nullptr;
} }
return CreateJ2000EquatorFrame(universe, value->getHash(), defaultCenter); return CreateJ2000EquatorFrame(universe, value->getHash(), defaultCenter);
} }
clog << "Frame definition does not have a valid frame type.\n"; GetLogger()->error("Frame definition does not have a valid frame type.\n");
return nullptr; return nullptr;
} }
@ -1893,12 +1891,12 @@ ReferenceFrame::SharedConstPtr CreateReferenceFrame(const Universe& universe,
if (frameValue->getType() == Value::StringType) if (frameValue->getType() == Value::StringType)
{ {
// TODO: handle named frames // TODO: handle named frames
clog << "Invalid syntax for frame definition.\n"; GetLogger()->error("Invalid syntax for frame definition.\n");
return nullptr; return nullptr;
} }
if (frameValue->getType() != Value::HashType) if (frameValue->getType() != Value::HashType)
{ {
clog << "Invalid syntax for frame definition.\n"; GetLogger()->error("Invalid syntax for frame definition.\n");
return nullptr; return nullptr;
} }

View File

@ -13,7 +13,6 @@
#include <cmath> #include <cmath>
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <celmath/intersect.h> #include <celmath/intersect.h>
#include <celutil/debug.h>
#include "body.h" #include "body.h"
#include "planetgrid.h" #include "planetgrid.h"
#include "render.h" #include "render.h"

View File

@ -73,7 +73,7 @@ std::ofstream hdrlog;
#include <celmath/distance.h> #include <celmath/distance.h>
#include <celmath/intersect.h> #include <celmath/intersect.h>
#include <celmath/geomutil.h> #include <celmath/geomutil.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/utf8.h> #include <celutil/utf8.h>
#include <celutil/timer.h> #include <celutil/timer.h>
#include <celttf/truetypefont.h> #include <celttf/truetypefont.h>
@ -98,6 +98,7 @@ using namespace Eigen;
using namespace std; using namespace std;
using namespace celestia; using namespace celestia;
using namespace celmath; using namespace celmath;
using celestia::util::GetLogger;
#define FOV 45.0f #define FOV 45.0f
#define NEAR_DIST 0.5f #define NEAR_DIST 0.5f
@ -5802,7 +5803,7 @@ Renderer::createShadowFBO()
FramebufferObject::DepthAttachment)); FramebufferObject::DepthAttachment));
if (!m_shadowFBO->isValid()) if (!m_shadowFBO->isValid())
{ {
clog << "Error creating shadow FBO.\n"; GetLogger()->warn("Error creating shadow FBO.\n");
m_shadowFBO = nullptr; m_shadowFBO = nullptr;
} }
} }

View File

@ -10,12 +10,12 @@
#include "rotationmanager.h" #include "rotationmanager.h"
#include <config.h> #include <config.h>
#include <celephem/samporient.h> #include <celephem/samporient.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
using namespace std; using namespace std;
using celestia::util::GetLogger;
static RotationModelManager* rotationModelManager = nullptr; static RotationModelManager* rotationModelManager = nullptr;
@ -44,7 +44,7 @@ fs::path RotationModelInfo::resolve(const fs::path& baseDir)
RotationModel* RotationModelInfo::load(const fs::path& filename) RotationModel* RotationModelInfo::load(const fs::path& filename)
{ {
DPRINTF(LOG_LEVEL_INFO, "Loading rotation model: %s\n", filename); GetLogger()->verbose("Loading rotation model: {}\n", filename);
return LoadSampledOrientation(filename); return LoadSampledOrientation(filename);
} }

View File

@ -8,7 +8,6 @@
// as published by the Free Software Foundation; either version 2 // as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <celutil/debug.h>
#include <cassert> #include <cassert>
#include "astro.h" #include "astro.h"
#include "selection.h" #include "selection.h"

View File

@ -15,12 +15,11 @@
#include <sstream> #include <sstream>
#include <iomanip> #include <iomanip>
#include <tuple> #include <tuple>
#include <fmt/ostream.h>
#include <fmt/printf.h> #include <fmt/printf.h>
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <celcompat/filesystem.h> #include <celcompat/filesystem.h>
#include <celmath/geomutil.h> #include <celmath/geomutil.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include "glsupport.h" #include "glsupport.h"
#include "vecgl.h" #include "vecgl.h"
#include "shadermanager.h" #include "shadermanager.h"
@ -29,6 +28,7 @@
using namespace celestia; using namespace celestia;
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using celestia::util::GetLogger;
// GLSL on Mac OS X appears to have a bug that precludes us from using structs // GLSL on Mac OS X appears to have a bug that precludes us from using structs
#define USE_GLSL_STRUCTS #define USE_GLSL_STRUCTS
@ -410,21 +410,21 @@ ShaderManager::getShader(const string& name)
uintmax_t fsSize = fs::file_size(fsName, ecf); uintmax_t fsSize = fs::file_size(fsName, ecf);
if (ecv || ecf) if (ecv || ecf)
{ {
fmt::print(cerr, "Failed to get file size of {} or {}\n", vsName, fsName); GetLogger()->error("Failed to get file size of {} or {}\n", vsName, fsName);
return getShader(name, errorVertexShaderSource, errorFragmentShaderSource); return getShader(name, errorVertexShaderSource, errorFragmentShaderSource);
} }
ifstream vsf(vsName.string()); ifstream vsf(vsName.string());
if (!vsf.good()) if (!vsf.good())
{ {
fmt::print(cerr, "Failed to open {}\n", vsName); GetLogger()->error("Failed to open {}\n", vsName);
return getShader(name, errorVertexShaderSource, errorFragmentShaderSource); return getShader(name, errorVertexShaderSource, errorFragmentShaderSource);
} }
ifstream fsf(fsName.string()); ifstream fsf(fsName.string());
if (!fsf.good()) if (!fsf.good())
{ {
fmt::print(cerr, "Failed to open {}\n", fsName); GetLogger()->error("Failed to open {}\n", fsName);
return getShader(name, errorVertexShaderSource, errorFragmentShaderSource); return getShader(name, errorVertexShaderSource, errorFragmentShaderSource);
} }

View File

@ -15,13 +15,12 @@
#include <limits> #include <limits>
#include <fmt/format.h> #include <fmt/format.h>
#include <fmt/printf.h> #include <fmt/printf.h>
#include <fmt/ostream.h>
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/tokenizer.h>
#include "astro.h" #include "astro.h"
#include "parser.h" #include "parser.h"
#include <celutil/tokenizer.h>
#include "texmanager.h" #include "texmanager.h"
#include "meshmanager.h" #include "meshmanager.h"
#include "universe.h" #include "universe.h"
@ -35,6 +34,7 @@
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using namespace celmath; using namespace celmath;
using celestia::util::GetLogger;
enum BodyType enum BodyType
{ {
@ -78,16 +78,11 @@ enum BodyType
The name and parent name are both mandatory. The name and parent name are both mandatory.
*/ */
static void errorMessagePrelude(const Tokenizer& tok)
{
cerr << fmt::sprintf(_("Error in .ssc file (line %d): "), tok.getLineNumber());
}
static void sscError(const Tokenizer& tok, static void sscError(const Tokenizer& tok,
const string& msg) const string& msg)
{ {
errorMessagePrelude(tok); GetLogger()->error(_("Error in .ssc file (line {}): {}\n"),
cerr << msg << '\n'; tok.getLineNumber(), msg);
} }
@ -296,7 +291,7 @@ TimelinePhase::SharedConstPtr CreateTimelinePhase(Body* body,
bool hasBeginning = ParseDate(phaseData, "Beginning", beginning); bool hasBeginning = ParseDate(phaseData, "Beginning", beginning);
if (!isFirstPhase && hasBeginning) if (!isFirstPhase && hasBeginning)
{ {
clog << "Error: Beginning can only be specified for initial phase of timeline.\n"; GetLogger()->error("Error: Beginning can only be specified for initial phase of timeline.\n");
return nullptr; return nullptr;
} }
@ -304,7 +299,7 @@ TimelinePhase::SharedConstPtr CreateTimelinePhase(Body* body,
bool hasEnding = ParseDate(phaseData, "Ending", ending); bool hasEnding = ParseDate(phaseData, "Ending", ending);
if (!isLastPhase && !hasEnding) if (!isLastPhase && !hasEnding)
{ {
clog << "Error: Ending is required for all timeline phases other than the final one.\n"; GetLogger()->error("Error: Ending is required for all timeline phases other than the final one.\n");
return nullptr; return nullptr;
} }
@ -350,7 +345,7 @@ TimelinePhase::SharedConstPtr CreateTimelinePhase(Body* body,
Orbit* orbit = CreateOrbit(orbitFrame->getCenter(), phaseData, path, usePlanetUnits); Orbit* orbit = CreateOrbit(orbitFrame->getCenter(), phaseData, path, usePlanetUnits);
if (!orbit) if (!orbit)
{ {
clog << "Error: missing orbit in timeline phase.\n"; GetLogger()->error("Error: missing orbit in timeline phase.\n");
return nullptr; return nullptr;
} }
@ -395,7 +390,7 @@ Timeline* CreateTimelineFromArray(Body* body,
Hash* phaseData = (*iter)->getHash(); Hash* phaseData = (*iter)->getHash();
if (phaseData == nullptr) if (phaseData == nullptr)
{ {
clog << "Error in timeline of '" << body->getName() << "': phase " << iter - timelineArray->begin() + 1 << " is not a property group.\n"; GetLogger()->error("Error in timeline of '{}': phase {} is not a property group.\n", body->getName(), iter - timelineArray->begin() + 1);
delete timeline; delete timeline;
return nullptr; return nullptr;
} }
@ -410,7 +405,9 @@ Timeline* CreateTimelineFromArray(Body* body,
isFirstPhase, isLastPhase, previousEnding); isFirstPhase, isLastPhase, previousEnding);
if (phase == nullptr) if (phase == nullptr)
{ {
clog << "Error in timeline of '" << body->getName() << "', phase " << iter - timelineArray->begin() + 1 << endl; GetLogger()->error("Error in timeline of '{}', phase {}.\n",
body->getName(),
iter - timelineArray->begin() + 1);
delete timeline; delete timeline;
return nullptr; return nullptr;
} }
@ -473,7 +470,7 @@ static bool CreateTimeline(Body* body,
{ {
if (value->getType() != Value::ArrayType) if (value->getType() != Value::ArrayType)
{ {
clog << "Error: Timeline must be an array\n"; GetLogger()->error("Error: Timeline must be an array\n");
return false; return false;
} }
@ -573,7 +570,7 @@ static bool CreateTimeline(Body* body,
} }
else else
{ {
clog << "No valid orbit specified for object '" << body->getName() << "'. Skipping.\n"; GetLogger()->error("No valid orbit specified for object '{}'. Skipping.\n", body->getName());
return false; return false;
} }
} }
@ -619,7 +616,7 @@ static bool CreateTimeline(Body* body,
{ {
if (beginning >= ending) if (beginning >= ending)
{ {
clog << "Beginning time must be before Ending time.\n"; GetLogger()->error("Beginning time must be before Ending time.\n");
delete rotationModel; delete rotationModel;
return false; return false;
} }
@ -639,7 +636,7 @@ static bool CreateTimeline(Body* body,
assert(phase != nullptr); assert(phase != nullptr);
if (phase == nullptr) if (phase == nullptr)
{ {
clog << "Internal error creating TimelinePhase.\n"; GetLogger()->error("Internal error creating TimelinePhase.\n");
return false; return false;
} }
@ -654,13 +651,13 @@ static bool CreateTimeline(Body* body,
// multiphase timelines. // multiphase timelines.
if (newOrbitFrame && isFrameCircular(*body->getOrbitFrame(0.0), ReferenceFrame::PositionFrame)) if (newOrbitFrame && isFrameCircular(*body->getOrbitFrame(0.0), ReferenceFrame::PositionFrame))
{ {
clog << "Orbit frame for " << body->getName() << " is nested too deep (probably circular)\n"; GetLogger()->error("Orbit frame for '{}' is nested too deep (probably circular)\n", body->getName());
return false; return false;
} }
if (newBodyFrame && isFrameCircular(*body->getBodyFrame(0.0), ReferenceFrame::OrientationFrame)) if (newBodyFrame && isFrameCircular(*body->getBodyFrame(0.0), ReferenceFrame::OrientationFrame))
{ {
clog << "Body frame for " << body->getName() << " is nested too deep (probably circular)\n"; GetLogger()->error("Body frame for '{}' is nested too deep (probably circular)\n", body->getName());
return false; return false;
} }
} }
@ -799,7 +796,7 @@ static Body* CreateBody(const string& name,
{ {
// Relative URL, the base directory is the current one, // Relative URL, the base directory is the current one,
// not the main installation directory // not the main installation directory
const string &p = path.string(); string p = path.string();
if (p[1] == ':') if (p[1] == ':')
// Absolute Windows path, file:/// is required // Absolute Windows path, file:/// is required
infoURL = "file:///" + p + "/" + infoURL; infoURL = "file:///" + p + "/" + infoURL;
@ -812,7 +809,8 @@ static Body* CreateBody(const string& name,
double t; double t;
if (planetData->getNumber("Albedo", t)) if (planetData->getNumber("Albedo", t))
{ {
DPRINTF(LOG_LEVEL_WARNING, "Deprecated parameter Albedo used in %s definition.\nUse GeomAlbedo & BondAlbedo instead.\n", name); // TODO: make this warn
GetLogger()->verbose("Deprecated parameter Albedo used in {} definition.\nUse GeomAlbedo & BondAlbedo instead.\n", name);
body->setGeomAlbedo((float) t); body->setGeomAlbedo((float) t);
} }
@ -829,7 +827,7 @@ static Body* CreateBody(const string& name,
} }
else else
{ {
fmt::print(cerr, _("Incorrect GeomAlbedo value: {}\n"), t); GetLogger()->error(_("Incorrect GeomAlbedo value: {}\n"), t);
} }
} }
@ -838,7 +836,7 @@ static Body* CreateBody(const string& name,
if (t >= 0.0 && t <= 1.0) if (t >= 0.0 && t <= 1.0)
body->setReflectivity((float) t); body->setReflectivity((float) t);
else else
fmt::print(cerr, _("Incorrect Reflectivity value: {}\n"), t); GetLogger()->error(_("Incorrect Reflectivity value: {}\n"), t);
} }
if (planetData->getNumber("BondAlbedo", t)) if (planetData->getNumber("BondAlbedo", t))
@ -846,7 +844,7 @@ static Body* CreateBody(const string& name,
if (t >= 0.0 && t <= 1.0) if (t >= 0.0 && t <= 1.0)
body->setBondAlbedo((float) t); body->setBondAlbedo((float) t);
else else
fmt::print(cerr, _("Incorrect BondAlbedo value: {}\n"), t); GetLogger()->error(_("Incorrect BondAlbedo value: {}\n"), t);
} }
if (planetData->getNumber("Temperature", t)) if (planetData->getNumber("Temperature", t))
@ -1249,8 +1247,7 @@ bool LoadSolarSystemObjects(istream& in,
} }
else else
{ {
errorMessagePrelude(tokenizer); sscError(tokenizer, fmt::sprintf(_("parent body '%s' of '%s' not found.\n"), parentName, primaryName));
cerr << fmt::sprintf(_("parent body '%s' of '%s' not found.\n"), parentName, primaryName);
} }
if (parentSystem != nullptr) if (parentSystem != nullptr)
@ -1260,8 +1257,7 @@ bool LoadSolarSystemObjects(istream& in,
{ {
if (disposition == DataDisposition::Add) if (disposition == DataDisposition::Add)
{ {
errorMessagePrelude(tokenizer); sscError(tokenizer, fmt::sprintf(_("warning duplicate definition of %s %s\n"), parentName, primaryName));
cerr << fmt::sprintf(_("warning duplicate definition of %s %s\n"), parentName, primaryName);
} }
else if (disposition == DataDisposition::Replace) else if (disposition == DataDisposition::Replace)
{ {
@ -1312,8 +1308,7 @@ bool LoadSolarSystemObjects(istream& in,
} }
else else
{ {
errorMessagePrelude(tokenizer); sscError(tokenizer, fmt::sprintf(_("parent body '%s' of '%s' not found.\n"), parentName, primaryName));
cerr << fmt::sprintf(_("parent body '%s' of '%s' not found.\n"), parentName, primaryName);
} }
} }
delete objectDataValue; delete objectDataValue;

View File

@ -11,7 +11,6 @@
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celengine/selection.h> #include <celengine/selection.h>
#include <cassert> #include <cassert>
#include <celutil/debug.h>
#include <config.h> #include <config.h>
#include "astro.h" #include "astro.h"
#include "star.h" #include "star.h"

View File

@ -16,7 +16,7 @@
#include <algorithm> #include <algorithm>
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celutil/binaryread.h> #include <celutil/binaryread.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/tokenizer.h> #include <celutil/tokenizer.h>
#include "stardb.h" #include "stardb.h"
@ -31,6 +31,7 @@
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using namespace celmath; using namespace celmath;
using celestia::util::GetLogger;
namespace celutil = celestia::util; namespace celutil = celestia::util;
@ -580,7 +581,7 @@ bool StarDatabase::loadCrossIndex(const Catalog catalog, istream& in)
if (!in.read(header, headerLength).good() if (!in.read(header, headerLength).good()
|| strncmp(header, CROSSINDEX_FILE_HEADER, headerLength)) || strncmp(header, CROSSINDEX_FILE_HEADER, headerLength))
{ {
cerr << _("Bad header for cross index\n"); GetLogger()->error(_("Bad header for cross index\n"));
delete[] header; delete[] header;
return false; return false;
} }
@ -592,7 +593,7 @@ bool StarDatabase::loadCrossIndex(const Catalog catalog, istream& in)
std::uint16_t version; std::uint16_t version;
if (!celutil::readLE<std::uint16_t>(in, version) || version != 0x0100) if (!celutil::readLE<std::uint16_t>(in, version) || version != 0x0100)
{ {
std::cerr << _("Bad version for cross index\n"); GetLogger()->error(_("Bad version for cross index\n"));
return false; return false;
} }
} }
@ -606,14 +607,14 @@ bool StarDatabase::loadCrossIndex(const Catalog catalog, istream& in)
if (!celutil::readLE<AstroCatalog::IndexNumber>(in, ent.catalogNumber)) if (!celutil::readLE<AstroCatalog::IndexNumber>(in, ent.catalogNumber))
{ {
if (in.eof()) { break; } if (in.eof()) { break; }
std::cerr << _("Loading cross index failed\n"); GetLogger()->error(_("Loading cross index failed\n"));
delete xindex; delete xindex;
return false; return false;
} }
if (!celutil::readLE<AstroCatalog::IndexNumber>(in, ent.celCatalogNumber)) if (!celutil::readLE<AstroCatalog::IndexNumber>(in, ent.celCatalogNumber))
{ {
std::cerr << fmt::sprintf(_("Loading cross index failed at record %u\n"), record); GetLogger()->error(_("Loading cross index failed at record {}\n"), record);
delete xindex; delete xindex;
return false; return false;
} }
@ -691,7 +692,7 @@ bool StarDatabase::loadBinary(istream& in)
if (details == nullptr) if (details == nullptr)
{ {
cerr << fmt::sprintf(_("Bad spectral type in star database, star #%u\n"), nStars); GetLogger()->error(_("Bad spectral type in star database, star #{}\n"), nStars);
return false; return false;
} }
@ -705,8 +706,8 @@ bool StarDatabase::loadBinary(istream& in)
if (in.bad()) if (in.bad())
return false; return false;
DPRINTF(LOG_LEVEL_ERROR, "StarDatabase::read: nStars = %d\n", nStarsInFile); GetLogger()->debug("StarDatabase::read: nStars = {}\n", nStarsInFile);
clog << fmt::sprintf(_("%d stars in binary database\n"), nStars); GetLogger()->info(_("{} stars in binary database\n"), nStars);
// Create the temporary list of stars sorted by catalog number; this // Create the temporary list of stars sorted by catalog number; this
// will be used to lookup stars during file loading. After loading is // will be used to lookup stars during file loading. After loading is
@ -730,7 +731,7 @@ bool StarDatabase::loadBinary(istream& in)
void StarDatabase::finish() void StarDatabase::finish()
{ {
clog << fmt::sprintf(_("Total star count: %d\n"), nStars); GetLogger()->info(_("Total star count: {}\n"), nStars);
buildOctree(); buildOctree();
buildIndexes(); buildIndexes();
@ -764,7 +765,7 @@ void StarDatabase::finish()
static void stcError(const Tokenizer& tok, static void stcError(const Tokenizer& tok,
const string& msg) const string& msg)
{ {
cerr << fmt::sprintf( _("Error in .stc file (line %i): %s\n"), tok.getLineNumber(), msg); GetLogger()->error(_("Error in .stc file (line {}): {}\n"), tok.getLineNumber(), msg);
} }
@ -794,7 +795,7 @@ bool StarDatabase::createStar(Star* star,
details = StarDetails::GetStarDetails(sc); details = StarDetails::GetStarDetails(sc);
if (details == nullptr) if (details == nullptr)
{ {
cerr << _("Invalid star: bad spectral type.\n"); GetLogger()->error(_("Invalid star: bad spectral type.\n"));
return false; return false;
} }
} }
@ -803,7 +804,7 @@ bool StarDatabase::createStar(Star* star,
// Spectral type is required for new stars // Spectral type is required for new stars
if (disposition != DataDisposition::Modify) if (disposition != DataDisposition::Modify)
{ {
cerr << _("Invalid star: missing spectral type.\n"); GetLogger()->error(_("Invalid star: missing spectral type.\n"));
return false; return false;
} }
} }
@ -990,7 +991,7 @@ bool StarDatabase::createStar(Star* star,
if (!hasBarycenter) if (!hasBarycenter)
{ {
cerr << fmt::sprintf(_("Barycenter %s does not exist.\n"), barycenterName); GetLogger()->error(_("Barycenter {} does not exist.\n"), barycenterName);
delete rm; delete rm;
if (free_details) if (free_details)
delete details; delete details;
@ -1046,7 +1047,7 @@ bool StarDatabase::createStar(Star* star,
{ {
if (disposition != DataDisposition::Modify) if (disposition != DataDisposition::Modify)
{ {
cerr << _("Invalid star: missing right ascension\n"); GetLogger()->error(_("Invalid star: missing right ascension\n"));
return false; return false;
} }
} }
@ -1059,7 +1060,7 @@ bool StarDatabase::createStar(Star* star,
{ {
if (disposition != DataDisposition::Modify) if (disposition != DataDisposition::Modify)
{ {
cerr << _("Invalid star: missing declination.\n"); GetLogger()->error(_("Invalid star: missing declination.\n"));
return false; return false;
} }
} }
@ -1072,7 +1073,7 @@ bool StarDatabase::createStar(Star* star,
{ {
if (disposition != DataDisposition::Modify) if (disposition != DataDisposition::Modify)
{ {
cerr << _("Invalid star: missing distance.\n"); GetLogger()->error(_("Invalid star: missing distance.\n"));
return false; return false;
} }
} }
@ -1106,7 +1107,7 @@ bool StarDatabase::createStar(Star* star,
{ {
if (disposition != DataDisposition::Modify) if (disposition != DataDisposition::Modify)
{ {
clog << _("Invalid star: missing magnitude.\n"); GetLogger()->error(_("Invalid star: missing magnitude.\n"));
return false; return false;
} }
else else
@ -1123,7 +1124,7 @@ bool StarDatabase::createStar(Star* star,
// origin. // origin.
if (distance < 1e-5f) if (distance < 1e-5f)
{ {
clog << _("Invalid star: absolute (not apparent) magnitude must be specified for star near origin\n"); GetLogger()->error(_("Invalid star: absolute (not apparent) magnitude must be specified for star near origin\n"));
return false; return false;
} }
magnitude = astro::appToAbsMag(magnitude, distance); magnitude = astro::appToAbsMag(magnitude, distance);
@ -1320,13 +1321,13 @@ bool StarDatabase::load(istream& in, const fs::path& resourcePath)
Value* starDataValue = parser.readValue(); Value* starDataValue = parser.readValue();
if (starDataValue == nullptr) if (starDataValue == nullptr)
{ {
clog << "Error reading star.\n"; GetLogger()->error("Error reading star.\n");
return false; return false;
} }
if (starDataValue->getType() != Value::HashType) if (starDataValue->getType() != Value::HashType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Bad star definition.\n"); GetLogger()->error("Bad star definition.\n");
delete starDataValue; delete starDataValue;
return false; return false;
} }
@ -1338,7 +1339,7 @@ bool StarDatabase::load(istream& in, const fs::path& resourcePath)
bool ok = false; bool ok = false;
if (isNewStar && disposition == DataDisposition::Modify) if (isNewStar && disposition == DataDisposition::Modify)
{ {
clog << "Modify requested for nonexistent star.\n"; GetLogger()->warn("Modify requested for nonexistent star.\n");
} }
else else
{ {
@ -1388,7 +1389,7 @@ bool StarDatabase::load(istream& in, const fs::path& resourcePath)
{ {
if (isNewStar) if (isNewStar)
delete star; delete star;
DPRINTF(LOG_LEVEL_INFO, "Bad star definition--will continue parsing file.\n"); GetLogger()->info("Bad star definition--will continue parsing file.\n");
} }
} }
@ -1401,7 +1402,7 @@ void StarDatabase::buildOctree()
// This should only be called once for the database // This should only be called once for the database
// ASSERT(octreeRoot == nullptr); // ASSERT(octreeRoot == nullptr);
DPRINTF(LOG_LEVEL_INFO, "Sorting stars into octree . . .\n"); GetLogger()->debug("Sorting stars into octree . . .\n");
float absMag = astro::appToAbsMag(STAR_OCTREE_MAGNITUDE, float absMag = astro::appToAbsMag(STAR_OCTREE_MAGNITUDE,
STAR_OCTREE_ROOT_SIZE * (float) sqrt(3.0)); STAR_OCTREE_ROOT_SIZE * (float) sqrt(3.0));
DynamicStarOctree* root = new DynamicStarOctree(Vector3f(1000.0f, 1000.0f, 1000.0f), DynamicStarOctree* root = new DynamicStarOctree(Vector3f(1000.0f, 1000.0f, 1000.0f),
@ -1411,14 +1412,14 @@ void StarDatabase::buildOctree()
root->insertObject(unsortedStars[i], STAR_OCTREE_ROOT_SIZE); root->insertObject(unsortedStars[i], STAR_OCTREE_ROOT_SIZE);
} }
DPRINTF(LOG_LEVEL_INFO, "Spatially sorting stars for improved locality of reference . . .\n"); GetLogger()->debug("Spatially sorting stars for improved locality of reference . . .\n");
Star* sortedStars = new Star[nStars]; Star* sortedStars = new Star[nStars];
Star* firstStar = sortedStars; Star* firstStar = sortedStars;
root->rebuildAndSort(octreeRoot, firstStar); root->rebuildAndSort(octreeRoot, firstStar);
// ASSERT((int) (firstStar - sortedStars) == nStars); // ASSERT((int) (firstStar - sortedStars) == nStars);
DPRINTF(LOG_LEVEL_INFO, "%d stars total\n", (int) (firstStar - sortedStars)); GetLogger()->debug("{} stars total\nOctree has {} nodes and {} stars.\n",
DPRINTF(LOG_LEVEL_INFO, "Octree has %d nodes and %d stars.\n", static_cast<int>(firstStar - sortedStars),
1 + octreeRoot->countChildren(), octreeRoot->countObjects()); 1 + octreeRoot->countChildren(), octreeRoot->countObjects());
#ifdef PROFILE_OCTREE #ifdef PROFILE_OCTREE
vector<OctreeLevelStatistics> stats; vector<OctreeLevelStatistics> stats;
@ -1450,7 +1451,7 @@ void StarDatabase::buildIndexes()
// This should only be called once for the database // This should only be called once for the database
// assert(catalogNumberIndexes[0] == nullptr); // assert(catalogNumberIndexes[0] == nullptr);
DPRINTF(LOG_LEVEL_INFO, "Building catalog number indexes . . .\n"); GetLogger()->info("Building catalog number indexes . . .\n");
catalogNumberIndex = new Star*[nStars]; catalogNumberIndex = new Star*[nStars];
for (int i = 0; i < nStars; ++i) for (int i = 0; i < nStars; ++i)

View File

@ -9,7 +9,6 @@
#include <cstring> #include <cstring>
#include <fmt/printf.h> #include <fmt/printf.h>
#include <celutil/debug.h>
#include <cassert> #include <cassert>
#include <config.h> #include <config.h>
#include "stellarclass.h" #include "stellarclass.h"

View File

@ -7,7 +7,7 @@
// as published by the Free Software Foundation; either version 2 // as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/fsutils.h> #include <celutil/fsutils.h>
#include <fstream> #include <fstream>
#include <array> #include <array>
@ -16,6 +16,7 @@
using namespace std; using namespace std;
using namespace celestia; using namespace celestia;
using celestia::util::GetLogger;
static TextureManager* textureManager = nullptr; static TextureManager* textureManager = nullptr;
@ -101,14 +102,10 @@ Texture* TextureInfo::load(const fs::path& name)
if (bumpHeight == 0.0f) if (bumpHeight == 0.0f)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Loading texture: %s\n", name); GetLogger()->debug("Loading texture: {}\n", name);
// cout << "Loading texture: " << name << '\n';
return LoadTextureFromFile(name, addressMode, mipMode); return LoadTextureFromFile(name, addressMode, mipMode);
} }
DPRINTF(LOG_LEVEL_ERROR, "Loading bump map: %s\n", name); GetLogger()->debug("Loading bump map: {}\n", name);
// cout << "Loading texture: " << name << '\n';
return LoadHeightMapFromFile(name, bumpHeight, addressMode); return LoadHeightMapFromFile(name, bumpHeight, addressMode);
} }

View File

@ -14,13 +14,12 @@
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <fmt/printf.h>
#include <Eigen/Core> #include <Eigen/Core>
#include "glsupport.h" #include "glsupport.h"
#include <celutil/filetype.h> #include <celutil/filetype.h>
#include <celutil/debug.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/logger.h>
#include "framebuffer.h" #include "framebuffer.h"
#include "texture.h" #include "texture.h"
#include "virtualtex.h" #include "virtualtex.h"
@ -29,6 +28,7 @@
using namespace celestia; using namespace celestia;
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using celestia::util::GetLogger;
struct TextureCaps struct TextureCaps
{ {
@ -925,12 +925,14 @@ static Texture* CreateTextureFromImage(Image& img,
// The texture is too large; we need to split it. // The texture is too large; we need to split it.
int uSplit = max(1, img.getWidth() / maxDim); int uSplit = max(1, img.getWidth() / maxDim);
int vSplit = max(1, img.getHeight() / maxDim); int vSplit = max(1, img.getHeight() / maxDim);
clog << fmt::sprintf(_("Creating tiled texture. Width=%i, max=%i\n"), img.getWidth(), maxDim); GetLogger()->info(_("Creating tiled texture. Width={}, max={}\n"),
img.getWidth(), maxDim);
tex = new TiledTexture(img, uSplit, vSplit, mipMode); tex = new TiledTexture(img, uSplit, vSplit, mipMode);
} }
else else
{ {
clog << fmt::sprintf(_("Creating ordinary texture: %ix%i\n"), img.getWidth(), img.getHeight()); GetLogger()->info(_("Creating ordinary texture: {}x{}\n"),
img.getWidth(), img.getHeight());
tex = new ImageTexture(img, addressMode, mipMode); tex = new ImageTexture(img, addressMode, mipMode);
} }

View File

@ -8,18 +8,16 @@
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <config.h> #include <config.h>
#include "trajmanager.h"
#include <celephem/samporbit.h>
#include <celutil/debug.h>
#include <celutil/filetype.h>
#include <iostream>
#include <fstream> #include <fstream>
#include <cassert> #include <cassert>
#include <celutil/debug.h>
#include <fmt/printf.h> #include <fmt/printf.h>
#include <celephem/samporbit.h>
#include <celutil/logger.h>
#include <celutil/filetype.h>
#include "trajmanager.h"
using namespace std; using namespace std;
using celestia::util::GetLogger;
static TrajectoryManager* trajectoryManager = nullptr; static TrajectoryManager* trajectoryManager = nullptr;
@ -65,7 +63,7 @@ Orbit* TrajectoryInfo::load(const fs::path& filename)
fs::path strippedFilename = filename.string().substr(0, uniquifyingSuffixStart); fs::path strippedFilename = filename.string().substr(0, uniquifyingSuffixStart);
ContentType filetype = DetermineFileType(strippedFilename); ContentType filetype = DetermineFileType(strippedFilename);
DPRINTF(LOG_LEVEL_INFO, "Loading trajectory: %s\n", strippedFilename); GetLogger()->debug("Loading trajectory: {}\n", strippedFilename);
Orbit* sampTrajectory = nullptr; Orbit* sampTrajectory = nullptr;

View File

@ -15,17 +15,17 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include <fmt/format.h> #include <fmt/format.h>
#include <celutil/debug.h>
#include "glsupport.h"
#include <celutil/debug.h>
#include <celcompat/filesystem.h> #include <celcompat/filesystem.h>
#include <celutil/filetype.h> #include <celutil/filetype.h>
#include "parser.h" #include <celutil/logger.h>
#include <celutil/tokenizer.h> #include <celutil/tokenizer.h>
#include "glsupport.h"
#include "parser.h"
#include "virtualtex.h" #include "virtualtex.h"
using namespace std; using namespace std;
using celestia::util::GetLogger;
static const int MaxResolutionLevels = 13; static const int MaxResolutionLevels = 13;
@ -317,7 +317,7 @@ static VirtualTexture* CreateVirtualTexture(Hash* texParams,
string imageDirectory; string imageDirectory;
if (!texParams->getString("ImageDirectory", imageDirectory)) if (!texParams->getString("ImageDirectory", imageDirectory))
{ {
DPRINTF(LOG_LEVEL_ERROR, "ImageDirectory missing in virtual texture.\n"); GetLogger()->error("ImageDirectory missing in virtual texture.\n");
return nullptr; return nullptr;
} }
@ -325,14 +325,14 @@ static VirtualTexture* CreateVirtualTexture(Hash* texParams,
if (!texParams->getNumber("BaseSplit", baseSplit) || if (!texParams->getNumber("BaseSplit", baseSplit) ||
baseSplit < 0.0 || baseSplit != floor(baseSplit)) baseSplit < 0.0 || baseSplit != floor(baseSplit))
{ {
DPRINTF(LOG_LEVEL_ERROR, "BaseSplit in virtual texture missing or has bad value\n"); GetLogger()->error("BaseSplit in virtual texture missing or has bad value\n");
return nullptr; return nullptr;
} }
double tileSize = 0.0; double tileSize = 0.0;
if (!texParams->getNumber("TileSize", tileSize)) if (!texParams->getNumber("TileSize", tileSize))
{ {
DPRINTF(LOG_LEVEL_ERROR, "TileSize is missing from virtual texture\n"); GetLogger()->error("TileSize is missing from virtual texture\n");
return nullptr; return nullptr;
} }
@ -340,7 +340,7 @@ static VirtualTexture* CreateVirtualTexture(Hash* texParams,
tileSize < 64.0 || tileSize < 64.0 ||
!isPow2((int) tileSize)) !isPow2((int) tileSize))
{ {
DPRINTF(LOG_LEVEL_ERROR, "Virtual texture tile size must be a power of two >= 64\n"); GetLogger()->error("Virtual texture tile size must be a power of two >= 64\n");
return nullptr; return nullptr;
} }
@ -379,7 +379,7 @@ static VirtualTexture* LoadVirtualTexture(istream& in, const fs::path& path)
Value* texParamsValue = parser.readValue(); Value* texParamsValue = parser.readValue();
if (texParamsValue == nullptr || texParamsValue->getType() != Value::HashType) if (texParamsValue == nullptr || texParamsValue->getType() != Value::HashType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error parsing virtual texture\n"); GetLogger()->error("Error parsing virtual texture\n");
delete texParamsValue; delete texParamsValue;
return nullptr; return nullptr;
} }
@ -399,7 +399,7 @@ VirtualTexture* LoadVirtualTexture(const fs::path& filename)
if (!in.good()) if (!in.good())
{ {
//DPRINTF(LOG_LEVEL_ERROR, "Error opening virtual texture file: %s\n", filename.c_str()); GetLogger()->error("Error opening virtual texture file: {}\n", filename);
return nullptr; return nullptr;
} }

View File

@ -13,15 +13,15 @@
#include <celengine/astro.h> #include <celengine/astro.h>
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celmath/geomutil.h> #include <celmath/geomutil.h>
#include <celutil/logger.h>
#include <cassert> #include <cassert>
#include <vector> #include <vector>
#include <fstream> #include <fstream>
#include <celutil/debug.h>
#include <fmt/ostream.h>
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using namespace celmath; using namespace celmath;
using celestia::util::GetLogger;
#define TWOPI 6.28318530717958647692 #define TWOPI 6.28318530717958647692
@ -3164,9 +3164,9 @@ Orbit* GetCustomOrbit(const string& name)
ephemType = fmt::format("DE{}", jpleph->getDENumber()); ephemType = fmt::format("DE{}", jpleph->getDENumber());
else else
ephemType = "INPOP"; ephemType = "INPOP";
fmt::print(clog, "Loaded {} ephemeris. Valid from JD {:.8f} to JD {:.8f}\n", GetLogger()->debug("Loaded {} ephemeris. Valid from JD {:.8f} to JD {:.8f}\n",
ephemType, jpleph->getStartDate(), jpleph->getEndDate()); ephemType, jpleph->getStartDate(), jpleph->getEndDate());
fmt::print(clog, "Ephemeris record size: {} doubles, with {} endianess.\n", GetLogger()->debug("Ephemeris record size: {} doubles, with {} endianess.\n",
jpleph->getRecordSize(), jpleph->getRecordSize(),
jpleph->getByteSwap() ? "non-native" : "native"); jpleph->getByteSwap() ? "non-native" : "native");
} }

View File

@ -299,7 +299,7 @@ double EllipticalOrbit::eccentricAnomaly(double M) const
// much faster converging iteration. // much faster converging iteration.
Solution sol = solve_iteration_fixed(SolveKeplerFunc2(eccentricity, M), M, 6); Solution sol = solve_iteration_fixed(SolveKeplerFunc2(eccentricity, M), M, 6);
// Debugging // Debugging
// DPRINTF(LOG_LEVEL_INFO, "ecc: %f, error: %f mas\n", // GetLogger()->debug("ecc: {}, error: {} mas\n",
// eccentricity, radToDeg(sol.second) * 3600000); // eccentricity, radToDeg(sol.second) * 3600000);
return sol.first; return sol.first;
} }

View File

@ -13,13 +13,11 @@
#include "orbit.h" #include "orbit.h"
#include "samporbit.h" #include "samporbit.h"
#include "xyzvbinary.h" #include "xyzvbinary.h"
#include <fmt/ostream.h>
#include <fmt/printf.h>
#include <celengine/astro.h> #include <celengine/astro.h>
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celutil/bytes.h> #include <celutil/bytes.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <cmath> #include <cmath>
#include <string> #include <string>
#include <algorithm> #include <algorithm>
@ -32,6 +30,7 @@
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using namespace celmath; using namespace celmath;
using celestia::util::GetLogger;
// Trajectories are sampled adaptively for rendering. MaxSampleInterval // Trajectories are sampled adaptively for rendering. MaxSampleInterval
// is the maximum time (in days) between samples. The threshold angle // is the maximum time (in days) between samples. The threshold angle
@ -832,26 +831,26 @@ LoadSampledOrbitXYZVBinary(const fs::path& filename, TrajectoryInterpolation int
ifstream in(filename.string(), ios::binary); ifstream in(filename.string(), ios::binary);
if (!in.good()) if (!in.good())
{ {
cerr << fmt::sprintf(_("Error opening %s.\n"), filename); GetLogger()->error(_("Error opening {}.\n"), filename);
return nullptr; return nullptr;
} }
XYZVBinaryHeader header; XYZVBinaryHeader header;
if (!in.read(reinterpret_cast<char*>(&header), sizeof(header))) if (!in.read(reinterpret_cast<char*>(&header), sizeof(header)))
{ {
cerr << fmt::sprintf(_("Error reading header of %s.\n"), filename); GetLogger()->error(_("Error reading header of {}.\n"), filename);
return nullptr; return nullptr;
} }
if (string(header.magic) != "CELXYZV") if (string(header.magic) != "CELXYZV")
{ {
cerr << fmt::sprintf(_("Bad binary xyzv file %s.\n"), filename); GetLogger()->error(_("Bad binary xyzv file {}.\n"), filename);
return nullptr; return nullptr;
} }
if (header.byteOrder != __BYTE_ORDER__) if (header.byteOrder != __BYTE_ORDER__)
{ {
cerr << fmt::sprintf(_("Unsupported byte order %i, expected %i.\n"), GetLogger()->error(_("Unsupported byte order {}, expected {}.\n"),
header.byteOrder, __BYTE_ORDER__); header.byteOrder, __BYTE_ORDER__);
return nullptr; return nullptr;
} }
@ -859,7 +858,7 @@ LoadSampledOrbitXYZVBinary(const fs::path& filename, TrajectoryInterpolation int
if (header.digits != std::numeric_limits<double>::digits) if (header.digits != std::numeric_limits<double>::digits)
{ {
cerr << fmt::sprintf(_("Unsupported digits number %i, expected %i.\n"), GetLogger()->error(_("Unsupported digits number {}, expected {}.\n"),
header.digits, std::numeric_limits<double>::digits); header.digits, std::numeric_limits<double>::digits);
return nullptr; return nullptr;
} }

View File

@ -9,7 +9,6 @@
// as published by the Free Software Foundation; either version 2 // as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <celutil/debug.h>
#include <fmt/printf.h> #include <fmt/printf.h>
#include "scriptobject.h" #include "scriptobject.h"

View File

@ -9,13 +9,13 @@
// as published by the Free Software Foundation; either version 2 // as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <cstdio> #include <celutil/logger.h>
#include <cassert>
#include "scriptobject.h" #include "scriptobject.h"
#include "scriptorbit.h" #include "scriptorbit.h"
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using celestia::util::GetLogger;
/*! Initialize the script orbit. /*! Initialize the script orbit.
@ -53,7 +53,7 @@ ScriptedOrbit::initialize(const std::string& moduleName,
luaState = GetScriptedObjectContext(); luaState = GetScriptedObjectContext();
if (luaState == nullptr) if (luaState == nullptr)
{ {
clog << "ScriptedOrbits are currently disabled.\n"; GetLogger()->warn("ScriptedOrbits are currently disabled.\n");
return false; return false;
} }
@ -62,7 +62,7 @@ ScriptedOrbit::initialize(const std::string& moduleName,
lua_getglobal(luaState, "require"); lua_getglobal(luaState, "require");
if (!lua_isfunction(luaState, -1)) if (!lua_isfunction(luaState, -1))
{ {
clog << "Cannot load ScriptedOrbit package: 'require' function is unavailable\n"; GetLogger()->error("Cannot load ScriptedOrbit package: 'require' function is unavailable\n");
lua_pop(luaState, 1); lua_pop(luaState, 1);
return false; return false;
} }
@ -70,7 +70,7 @@ ScriptedOrbit::initialize(const std::string& moduleName,
lua_pushstring(luaState, moduleName.c_str()); lua_pushstring(luaState, moduleName.c_str());
if (lua_pcall(luaState, 1, 1, 0) != 0) if (lua_pcall(luaState, 1, 1, 0) != 0)
{ {
clog << "Failed to load module for ScriptedOrbit: " << lua_tostring(luaState, -1) << "\n"; GetLogger()->error("Failed to load module for ScriptedOrbit: {}\n", lua_tostring(luaState, -1));
lua_pop(luaState, 1); lua_pop(luaState, 1);
return false; return false;
} }
@ -84,7 +84,7 @@ ScriptedOrbit::initialize(const std::string& moduleName,
// No function with the requested name; pop whatever value we // No function with the requested name; pop whatever value we
// did receive along with the table of arguments. // did receive along with the table of arguments.
lua_pop(luaState, 1); lua_pop(luaState, 1);
clog << "No Lua function named " << funcName << " found.\n"; GetLogger()->error("No Lua function named {} found.\n", funcName);
return false; return false;
} }
@ -97,8 +97,8 @@ ScriptedOrbit::initialize(const std::string& moduleName,
if (lua_pcall(luaState, 1, 1, 0) != 0) if (lua_pcall(luaState, 1, 1, 0) != 0)
{ {
// Some sort of error occurred--the error message is atop the stack // Some sort of error occurred--the error message is atop the stack
clog << "Error calling ScriptedOrbit generator function: " << GetLogger()->error("Error calling ScriptedOrbit generator function: {}\n",
lua_tostring(luaState, -1) << "\n"; lua_tostring(luaState, -1));
lua_pop(luaState, 1); lua_pop(luaState, 1);
return false; return false;
} }
@ -107,7 +107,7 @@ ScriptedOrbit::initialize(const std::string& moduleName,
{ {
// We have an object, but it's not a table. Pop it off the // We have an object, but it's not a table. Pop it off the
// stack and report failure. // stack and report failure.
clog << "ScriptedOrbit generator function returned bad value.\n"; GetLogger()->error("ScriptedOrbit generator function returned bad value.\n");
lua_pop(luaState, 1); lua_pop(luaState, 1);
return false; return false;
} }
@ -124,7 +124,7 @@ ScriptedOrbit::initialize(const std::string& moduleName,
lua_gettable(luaState, -2); lua_gettable(luaState, -2);
if (lua_isnumber(luaState, -1) == 0) if (lua_isnumber(luaState, -1) == 0)
{ {
clog << "Bad or missing boundingRadius for ScriptedOrbit object\n"; GetLogger()->error("Bad or missing boundingRadius for ScriptedOrbit object\n");
lua_pop(luaState, 1); lua_pop(luaState, 1);
return false; return false;
} }
@ -143,13 +143,13 @@ ScriptedOrbit::initialize(const std::string& moduleName,
// Perform some sanity checks on the orbit parameters // Perform some sanity checks on the orbit parameters
if (validRangeEnd < validRangeBegin) if (validRangeEnd < validRangeBegin)
{ {
clog << "Bad script orbit: valid range end < begin\n"; GetLogger()->error("Bad script orbit: valid range end < begin\n");
return false; return false;
} }
if (boundingRadius <= 0.0) if (boundingRadius <= 0.0)
{ {
clog << "Bad script object: bounding radius must be positive\n"; GetLogger()->error("Bad script object: bounding radius must be positive\n");
return false; return false;
} }

View File

@ -9,13 +9,13 @@
// as published by the Free Software Foundation; either version 2 // as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <cstdio> #include <celutil/logger.h>
#include <cassert>
#include "scriptobject.h" #include "scriptobject.h"
#include "scriptrotation.h" #include "scriptrotation.h"
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using celestia::util::GetLogger;
/*! Initialize the script rotation /*! Initialize the script rotation
@ -51,7 +51,7 @@ ScriptedRotation::initialize(const std::string& moduleName,
luaState = GetScriptedObjectContext(); luaState = GetScriptedObjectContext();
if (luaState == nullptr) if (luaState == nullptr)
{ {
clog << "ScriptedRotations are currently disabled.\n"; GetLogger()->warn("ScriptedRotations are currently disabled.\n");
return false; return false;
} }
@ -60,7 +60,7 @@ ScriptedRotation::initialize(const std::string& moduleName,
lua_getglobal(luaState, "require"); lua_getglobal(luaState, "require");
if (!lua_isfunction(luaState, -1)) if (!lua_isfunction(luaState, -1))
{ {
clog << "Cannot load ScriptedRotation package: 'require' function is unavailable\n"; GetLogger()->error("Cannot load ScriptedRotation package: 'require' function is unavailable\n");
lua_pop(luaState, 1); lua_pop(luaState, 1);
return false; return false;
} }
@ -68,7 +68,7 @@ ScriptedRotation::initialize(const std::string& moduleName,
lua_pushstring(luaState, moduleName.c_str()); lua_pushstring(luaState, moduleName.c_str());
if (lua_pcall(luaState, 1, 1, 0) != 0) if (lua_pcall(luaState, 1, 1, 0) != 0)
{ {
clog << "Failed to load module for ScriptedRotation: " << lua_tostring(luaState, -1) << "\n"; GetLogger()->error("Failed to load module for ScriptedRotation: {}\n", lua_tostring(luaState, -1));
lua_pop(luaState, 1); lua_pop(luaState, 1);
return false; return false;
} }
@ -82,7 +82,7 @@ ScriptedRotation::initialize(const std::string& moduleName,
// No function with the requested name; pop whatever value we // No function with the requested name; pop whatever value we
// did receive along with the table of arguments. // did receive along with the table of arguments.
lua_pop(luaState, 1); lua_pop(luaState, 1);
clog << "No Lua function named " << funcName << " found.\n"; GetLogger()->error("No Lua function named {} found.\n", funcName);
return false; return false;
} }
@ -95,8 +95,8 @@ ScriptedRotation::initialize(const std::string& moduleName,
if (lua_pcall(luaState, 1, 1, 0) != 0) if (lua_pcall(luaState, 1, 1, 0) != 0)
{ {
// Some sort of error occurred--the error message is atop the stack // Some sort of error occurred--the error message is atop the stack
clog << "Error calling ScriptedRotation generator function: " << GetLogger()->error("Error calling ScriptedRotation generator function: {}\n",
lua_tostring(luaState, -1) << "\n"; lua_tostring(luaState, -1));
lua_pop(luaState, 1); lua_pop(luaState, 1);
return false; return false;
} }
@ -105,7 +105,7 @@ ScriptedRotation::initialize(const std::string& moduleName,
{ {
// We have an object, but it's not a table. Pop it off the // We have an object, but it's not a table. Pop it off the
// stack and report failure. // stack and report failure.
clog << "ScriptedRotation generator function returned bad value.\n"; GetLogger()->error("ScriptedRotation generator function returned bad value.\n");
lua_pop(luaState, 1); lua_pop(luaState, 1);
return false; return false;
} }
@ -126,7 +126,7 @@ ScriptedRotation::initialize(const std::string& moduleName,
// Perform some sanity checks on the rotation parameters // Perform some sanity checks on the rotation parameters
if (validRangeEnd < validRangeBegin) if (validRangeEnd < validRangeBegin)
{ {
clog << "Bad script rotation: valid range end < begin\n"; GetLogger()->error("Bad script rotation: valid range end < begin\n");
return false; return false;
} }
@ -161,7 +161,7 @@ ScriptedRotation::spin(double tjd) const
else else
{ {
// Function call failed for some reason // Function call failed for some reason
//clog << "ScriptedRotation failed: " << lua_tostring(luaState, -1) << "\n"; GetLogger()->warn("ScriptedRotation failed: {}\n", lua_tostring(luaState, -1));
lua_pop(luaState, 1); lua_pop(luaState, 1);
} }
} }

View File

@ -14,8 +14,10 @@
#include <iostream> #include <iostream>
#include <cstdio> #include <cstdio>
#include <set> #include <set>
#include <celutil/logger.h>
using namespace std; using namespace std;
using celestia::util::GetLogger;
// Track loaded SPICE kernels in order to avoid loading the same kernel // Track loaded SPICE kernels in order to avoid loading the same kernel
@ -99,7 +101,7 @@ bool LoadSpiceKernel(const fs::path& filepath)
{ {
char errMsg[1024]; char errMsg[1024];
getmsg_c("long", sizeof(errMsg), errMsg); getmsg_c("long", sizeof(errMsg), errMsg);
clog << errMsg << "\n"; GetLogger()->error("{}\n", errMsg);
// Reset the SPICE error state so that future calls to // Reset the SPICE error state so that future calls to
// SPICE can still succeed. // SPICE can still succeed.
@ -108,6 +110,6 @@ bool LoadSpiceKernel(const fs::path& filepath)
return false; return false;
} }
clog << "Loaded SPK file " << filepath << "\n"; GetLogger()->info("Loaded SPK file {}\n", filepath);
return true; return true;
} }

View File

@ -14,12 +14,13 @@
#include <utility> #include <utility>
#include "SpiceUsr.h" #include "SpiceUsr.h"
#include <celengine/astro.h> #include <celengine/astro.h>
#include <celutil/logger.h>
#include "spiceorbit.h" #include "spiceorbit.h"
#include "spiceinterface.h" #include "spiceinterface.h"
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using celestia::util::GetLogger;
static const double MILLISEC = astro::secsToDays(0.001); static const double MILLISEC = astro::secsToDays(0.001);
@ -105,14 +106,14 @@ SpiceOrbit::init(const fs::path& path,
// Get the ID codes for the target // Get the ID codes for the target
if (!GetNaifId(targetBodyName, &targetID)) if (!GetNaifId(targetBodyName, &targetID))
{ {
clog << "Couldn't find SPICE ID for " << targetBodyName << "\n"; GetLogger()->error("Couldn't find SPICE ID for {}\n", targetBodyName);
spiceErr = true; spiceErr = true;
return false; return false;
} }
if (!GetNaifId(originName, &originID)) if (!GetNaifId(originName, &originID))
{ {
clog << "Couldn't find SPICE ID for " << originName << "\n"; GetLogger()->error("Couldn't find SPICE ID for {}", originName);
spiceErr = true; spiceErr = true;
return false; return false;
} }
@ -151,7 +152,7 @@ SpiceOrbit::init(const fs::path& path,
SpiceInt nIntervals = card_c(&targetCoverage) / 2; SpiceInt nIntervals = card_c(&targetCoverage) / 2;
if (nIntervals <= 0 && targetID != 0) if (nIntervals <= 0 && targetID != 0)
{ {
clog << "Couldn't find object " << targetBodyName << " in SPICE kernel pool.\n"; GetLogger()->error("Couldn't find object {} in SPICE kernel pool.\n", targetBodyName);
spiceErr = true; spiceErr = true;
if (failed_c()) if (failed_c())
{ {
@ -202,7 +203,7 @@ SpiceOrbit::init(const fs::path& path,
if (targetID != 0 && if (targetID != 0 &&
!wnincd_c(beginningSecondsJ2000, endingSecondsJ2000, &targetCoverage)) !wnincd_c(beginningSecondsJ2000, endingSecondsJ2000, &targetCoverage))
{ {
clog << "Specified time interval for target " << targetBodyName << " not available.\n"; GetLogger()->error("Specified time interval for target {} not available.\n", targetBodyName);
return false; return false;
} }
} }
@ -222,7 +223,7 @@ SpiceOrbit::init(const fs::path& path,
// Print the error message // Print the error message
char errMsg[1024]; char errMsg[1024];
getmsg_c("long", sizeof(errMsg), errMsg); getmsg_c("long", sizeof(errMsg), errMsg);
clog << errMsg << "\n"; GetLogger()->error("{}\n", errMsg);
spiceErr = true; spiceErr = true;
reset_c(); reset_c();
@ -265,7 +266,7 @@ SpiceOrbit::computePosition(double jd) const
// Print the error message // Print the error message
char errMsg[1024]; char errMsg[1024];
getmsg_c("long", sizeof(errMsg), errMsg); getmsg_c("long", sizeof(errMsg), errMsg);
clog << errMsg << "\n"; GetLogger()->warn("{}\n", errMsg);
// Reset the error state // Reset the error state
reset_c(); reset_c();
@ -310,7 +311,7 @@ SpiceOrbit::computeVelocity(double jd) const
// Print the error message // Print the error message
char errMsg[1024]; char errMsg[1024];
getmsg_c("long", sizeof(errMsg), errMsg); getmsg_c("long", sizeof(errMsg), errMsg);
clog << errMsg << "\n"; GetLogger()->warn("{}\n", errMsg);
// Reset the error state // Reset the error state
reset_c(); reset_c();

View File

@ -15,6 +15,7 @@
#include <celengine/astro.h> #include <celengine/astro.h>
#include <celmath/geomutil.h> #include <celmath/geomutil.h>
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celutil/logger.h>
#include "SpiceUsr.h" #include "SpiceUsr.h"
#include <iostream> #include <iostream>
#include <cstdio> #include <cstdio>
@ -23,7 +24,7 @@
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using namespace celmath; using namespace celmath;
using celestia::util::GetLogger;
static const double MILLISEC = astro::secsToDays(0.001); static const double MILLISEC = astro::secsToDays(0.001);
static const Quaterniond Rx90 = XRotation(PI / 2.0); static const Quaterniond Rx90 = XRotation(PI / 2.0);
@ -124,7 +125,7 @@ SpiceRotation::init(const fs::path& path,
// Print the error message // Print the error message
char errMsg[1024]; char errMsg[1024];
getmsg_c("long", sizeof(errMsg), errMsg); getmsg_c("long", sizeof(errMsg), errMsg);
clog << errMsg << "\n"; GetLogger()->error("{}\n", errMsg);
m_spiceErr = true; m_spiceErr = true;
reset_c(); reset_c();
@ -159,7 +160,7 @@ SpiceRotation::computeSpin(double jd) const
// Print the error message // Print the error message
char errMsg[1024]; char errMsg[1024];
getmsg_c("long", sizeof(errMsg), errMsg); getmsg_c("long", sizeof(errMsg), errMsg);
clog << errMsg << "\n"; GetLogger()->error("{}\n", errMsg);
// Reset the error state // Reset the error state
reset_c(); reset_c();

View File

@ -10,10 +10,12 @@
#include <windowsx.h> #include <windowsx.h>
#include <celengine/pixelformat.h> #include <celengine/pixelformat.h>
#include <celengine/render.h> #include <celengine/render.h>
#include <celutil/logger.h>
#include "avicapture.h" #include "avicapture.h"
using namespace std; using namespace std;
using namespace celestia; using namespace celestia;
using celestia::util::GetLogger;
AVICapture::AVICapture(const Renderer *r) : AVICapture::AVICapture(const Renderer *r) :
MovieCapture(r) MovieCapture(r)
@ -57,7 +59,7 @@ bool AVICapture::start(const fs::path& filename,
nullptr); nullptr);
if (hr != AVIERR_OK) if (hr != AVIERR_OK)
{ {
DPRINTF(0, "Erroring creating avi file for capture.\n"); GetLogger()->error("Erroring creating avi file for capture.\n");
return false; return false;
} }
@ -72,7 +74,7 @@ bool AVICapture::start(const fs::path& filename,
hr = AVIFileCreateStream(aviFile, &aviStream, &info); hr = AVIFileCreateStream(aviFile, &aviStream, &info);
if (hr != AVIERR_OK) if (hr != AVIERR_OK)
{ {
DPRINTF(0, "Error %08x creating AVI stream.\n", hr); GetLogger()->error("Error {:08x} creating AVI stream.\n", hr);
cleanup(); cleanup();
return false; return false;
} }
@ -93,7 +95,7 @@ bool AVICapture::start(const fs::path& filename,
hr = AVIMakeCompressedStream(&compAviStream, aviStream, &options, nullptr); hr = AVIMakeCompressedStream(&compAviStream, aviStream, &options, nullptr);
if (hr != AVIERR_OK) if (hr != AVIERR_OK)
{ {
DPRINTF(0, "Error %08x creating compressed AVI stream.\n", hr); GetLogger()->error("Error {:08x} creating compressed AVI stream.\n", hr);
cleanup(); cleanup();
return false; return false;
} }
@ -115,7 +117,7 @@ bool AVICapture::start(const fs::path& filename,
hr = AVIStreamSetFormat(compAviStream, 0, &bi, sizeof bi); hr = AVIStreamSetFormat(compAviStream, 0, &bi, sizeof bi);
if (hr != AVIERR_OK) if (hr != AVIERR_OK)
{ {
DPRINTF(0, "AVIStreamSetFormat failed: %08x\n", hr); GetLogger()->error("AVIStreamSetFormat failed: {:08x}\n", hr);
cleanup(); cleanup();
return false; return false;
} }
@ -165,7 +167,7 @@ bool AVICapture::captureFrame()
&bytesWritten); &bytesWritten);
if (hr != AVIERR_OK) if (hr != AVIERR_OK)
{ {
DPRINTF(0, "AVIStreamWrite failed on frame %d\n", frameCounter); GetLogger()->error("AVIStreamWrite failed on frame {}\n", frameCounter);
return false; return false;
} }

View File

@ -37,7 +37,7 @@
#include <celutil/filetype.h> #include <celutil/filetype.h>
#include <celutil/formatnum.h> #include <celutil/formatnum.h>
#include <celutil/fsutils.h> #include <celutil/fsutils.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/utf8.h> #include <celutil/utf8.h>
#include <celcompat/filesystem.h> #include <celcompat/filesystem.h>
@ -90,10 +90,6 @@ static const double OneFtInKm = 0.0003048;
static const double OneLbInKg = 0.45359237; static const double OneLbInKg = 0.45359237;
static const double OneLbPerFt3InKgPerM3 = OneLbInKg / pow(OneFtInKm * 1000.0, 3); static const double OneLbPerFt3InKgPerM3 = OneLbInKg / pow(OneFtInKm * 1000.0, 3);
static void warning(string s)
{
cout << s;
}
static bool is_valid_directory(const fs::path& dir) static bool is_valid_directory(const fs::path& dir)
{ {
@ -103,7 +99,7 @@ static bool is_valid_directory(const fs::path& dir)
std::error_code ec; std::error_code ec;
if (!fs::is_directory(dir, ec)) if (!fs::is_directory(dir, ec))
{ {
cerr << fmt::sprintf(_("Path %s doesn't exist or isn't a directory\n"), dir); GetLogger()->error(_("Path {} doesn't exist or isn't a directory\n"), dir);
return false; return false;
} }
@ -156,6 +152,8 @@ CelestiaCore::CelestiaCore() :
m_tee(std::cout, std::cerr) m_tee(std::cout, std::cerr)
{ {
CreateLogger();
for (int i = 0; i < KeyCount; i++) for (int i = 0; i < KeyCount; i++)
{ {
keysPressed[i] = false; keysPressed[i] = false;
@ -179,6 +177,8 @@ CelestiaCore::~CelestiaCore()
if (m_logfile.good()) if (m_logfile.good())
m_logfile.close(); m_logfile.close();
DestroyLogger();
} }
void CelestiaCore::readFavoritesFile() void CelestiaCore::readFavoritesFile()
@ -200,7 +200,7 @@ void CelestiaCore::readFavoritesFile()
{ {
favorites = ReadFavoritesList(in); favorites = ReadFavoritesList(in);
if (favorites == nullptr) if (favorites == nullptr)
warning(fmt::format(_("Error reading favorites file {}.\n"), path)); GetLogger()->error(_("Error reading favorites file {}.\n"), path);
} }
} }
@ -221,7 +221,7 @@ void CelestiaCore::writeFavoritesFile()
bool isDir = fs::is_directory(path.parent_path(), ec); bool isDir = fs::is_directory(path.parent_path(), ec);
if (ec) if (ec)
{ {
warning(fmt::format(_("Failed to check directory existance for favorites file {}\n"), path)); GetLogger()->error(_("Failed to check directory existance for favorites file {}\n"), path);
return; return;
} }
if (!isDir) if (!isDir)
@ -229,7 +229,7 @@ void CelestiaCore::writeFavoritesFile()
fs::create_directory(path.parent_path(), ec); fs::create_directory(path.parent_path(), ec);
if (ec) if (ec)
{ {
warning(fmt::format(_("Failed to create a directory for favorites file {}\n"), path)); GetLogger()->error(_("Failed to create a directory for favorites file {}\n"), path);
return; return;
} }
} }
@ -312,7 +312,7 @@ void showSelectionInfo(const Selection& sel)
AngleAxisf aa(orientation); AngleAxisf aa(orientation);
DPRINTF(LOG_LEVEL_VERBOSE, "%s\nOrientation: [%f, %f, %f], %.1f\n", sel.getName(), aa.axis().x(), aa.axis().y(), aa.axis().z(), radToDeg(aa.angle())); GetLogger()->info("{}\nOrientation: [{}, {}, {}], {:.1f}\n", sel.getName(), aa.axis().x(), aa.axis().y(), aa.axis().z(), radToDeg(aa.angle()));
} }
@ -2210,7 +2210,7 @@ void CelestiaCore::draw(View* view)
if (viewportEffect->render(renderer, fbo, viewWidth, viewHeight)) if (viewportEffect->render(renderer, fbo, viewWidth, viewHeight))
viewportEffectUsed = true; viewportEffectUsed = true;
else else
DPRINTF(LOG_LEVEL_ERROR, "Unable to render viewport effect.\n"); GetLogger()->error("Unable to render viewport effect.\n");
} }
isViewportEffectUsed = viewportEffectUsed; isViewportEffectUsed = viewportEffectUsed;
} }
@ -3638,10 +3638,10 @@ class SolarSystemLoader
if (find(begin(skip), end(skip), filepath) != end(skip)) if (find(begin(skip), end(skip), filepath) != end(skip))
{ {
clog << fmt::sprintf(_("Skipping solar system catalog: %s\n"), filepath); GetLogger()->info(_("Skipping solar system catalog: {}\n"), filepath);
return; return;
} }
clog << fmt::sprintf(_("Loading solar system catalog: %s\n"), filepath); GetLogger()->info(_("Loading solar system catalog: {}\n"), filepath);
if (notifier != nullptr) if (notifier != nullptr)
notifier->update(filepath.filename().string()); notifier->update(filepath.filename().string());
@ -3684,10 +3684,10 @@ template <class OBJDB> class CatalogLoader
if (find(begin(skip), end(skip), filepath) != end(skip)) if (find(begin(skip), end(skip), filepath) != end(skip))
{ {
clog << fmt::sprintf(_("Skipping %s catalog: %s\n"), typeDesc, filepath); GetLogger()->info(_("Skipping {} catalog: {}\n"), typeDesc, filepath);
return; return;
} }
clog << fmt::sprintf(_("Loading %s catalog: %s\n"), typeDesc, filepath); GetLogger()->info(_("Loading {} catalog: {}\n"), typeDesc, filepath);
if (notifier != nullptr) if (notifier != nullptr)
notifier->update(filepath.filename().string()); notifier->update(filepath.filename().string());
@ -3695,7 +3695,7 @@ template <class OBJDB> class CatalogLoader
if (catalogFile.good()) if (catalogFile.good())
{ {
if (!objDB->load(catalogFile, filepath.parent_path())) if (!objDB->load(catalogFile, filepath.parent_path()))
DPRINTF(LOG_LEVEL_ERROR, "Error reading %s catalog file: %s\n", typeDesc, filepath); GetLogger()->error(_("Error reading {} catalog file: {}\n"), typeDesc, filepath);
} }
} }
}; };
@ -3798,11 +3798,11 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName,
ifstream dsoFile(file.string(), ios::in); ifstream dsoFile(file.string(), ios::in);
if (!dsoFile.good()) if (!dsoFile.good())
{ {
warning(fmt::sprintf(_("Error opening deepsky catalog file %s.\n"), file)); GetLogger()->error(_("Error opening deepsky catalog file {}.\n"), file);
} }
if (!dsoDB->load(dsoFile, "")) if (!dsoDB->load(dsoFile, ""))
{ {
warning(fmt::sprintf(_("Cannot read Deep Sky Objects database %s.\n"), file)); GetLogger()->error(_("Cannot read Deep Sky Objects database {}.\n"), file);
} }
} }
@ -3851,7 +3851,7 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName,
ifstream solarSysFile(file.string(), ios::in); ifstream solarSysFile(file.string(), ios::in);
if (!solarSysFile.good()) if (!solarSysFile.good())
{ {
warning(fmt::sprintf(_("Error opening solar system catalog %s.\n"), file)); GetLogger()->error(_("Error opening solar system catalog {}.\n"), file);
} }
else else
{ {
@ -3891,8 +3891,8 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName,
ifstream asterismsFile(config->asterismsFile.string(), ios::in); ifstream asterismsFile(config->asterismsFile.string(), ios::in);
if (!asterismsFile.good()) if (!asterismsFile.good())
{ {
warning(fmt::sprintf(_("Error opening asterisms file %s.\n"), GetLogger()->error(_("Error opening asterisms file {}.\n"),
config->asterismsFile)); config->asterismsFile);
} }
else else
{ {
@ -3907,8 +3907,8 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName,
ifstream boundariesFile(config->boundariesFile.string(), ios::in); ifstream boundariesFile(config->boundariesFile.string(), ios::in);
if (!boundariesFile.good()) if (!boundariesFile.good())
{ {
warning(fmt::sprintf(_("Error opening constellation boundaries file %s.\n"), GetLogger()->error(_("Error opening constellation boundaries file {}.\n"),
config->boundariesFile)); config->boundariesFile);
} }
else else
{ {
@ -3935,7 +3935,7 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName,
else if (config->projectionMode == "fisheye") else if (config->projectionMode == "fisheye")
renderer->setProjectionMode(Renderer::ProjectionMode::FisheyeMode); renderer->setProjectionMode(Renderer::ProjectionMode::FisheyeMode);
else else
DPRINTF(LOG_LEVEL_WARNING, "Unknown projection mode %s\n", config->projectionMode); GetLogger()->warn("Unknown projection mode {}\n", config->projectionMode);
} }
if (!config->viewportEffect.empty() && config->viewportEffect != "none") if (!config->viewportEffect.empty() && config->viewportEffect != "none")
@ -3946,7 +3946,7 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName,
{ {
if (config->warpMeshFile.empty()) if (config->warpMeshFile.empty())
{ {
DPRINTF(LOG_LEVEL_WARNING, "No warp mesh file specified for this effect\n"); GetLogger()->warn("No warp mesh file specified for this effect\n");
} }
else else
{ {
@ -3955,11 +3955,13 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName,
if (mesh != nullptr) if (mesh != nullptr)
viewportEffect = unique_ptr<ViewportEffect>(new WarpMeshViewportEffect(mesh)); viewportEffect = unique_ptr<ViewportEffect>(new WarpMeshViewportEffect(mesh));
else else
DPRINTF(LOG_LEVEL_WARNING, "Failed to read warp mesh file %s\n", config->warpMeshFile); GetLogger()->error("Failed to read warp mesh file {}\n", config->warpMeshFile);
} }
} }
else else
DPRINTF(LOG_LEVEL_WARNING, "Unknown viewport effect %s\n", config->viewportEffect); {
GetLogger()->warn("Unknown viewport effect {}\n", config->viewportEffect);
}
} }
if (!config->measurementSystem.empty()) if (!config->measurementSystem.empty())
@ -3969,7 +3971,7 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName,
else if (compareIgnoringCase(config->measurementSystem, "metric") == 0) else if (compareIgnoringCase(config->measurementSystem, "metric") == 0)
measurement = Metric; measurement = Metric;
else else
DPRINTF(LOG_LEVEL_WARNING, "Unknown measurement system %s\n", config->measurementSystem); GetLogger()->warn("Unknown measurement system {}\n", config->measurementSystem);
} }
sim = new Simulation(universe); sim = new Simulation(universe);
@ -4022,7 +4024,7 @@ bool CelestiaCore::initRenderer()
context->init(config->ignoreGLExtensions); context->init(config->ignoreGLExtensions);
// Choose the render path, starting with the least desirable // Choose the render path, starting with the least desirable
context->setRenderPath(GLContext::GLPath_GLSL); context->setRenderPath(GLContext::GLPath_GLSL);
//DPRINTF(LOG_LEVEL_VERBOSE, "render path: %i\n", context->getRenderPath()); //GetLogger()->verbose("render path: {}\n", context->getRenderPath());
#endif #endif
Renderer::DetailOptions detailOptions; Renderer::DetailOptions detailOptions;
@ -4104,9 +4106,9 @@ static void loadCrossIndex(StarDatabase* starDB,
if (xrefFile.good()) if (xrefFile.good())
{ {
if (!starDB->loadCrossIndex(catalog, xrefFile)) if (!starDB->loadCrossIndex(catalog, xrefFile))
cerr << fmt::sprintf(_("Error reading cross index %s\n"), filename); GetLogger()->error(_("Error reading cross index {}\n"), filename);
else else
clog << fmt::sprintf(_("Loaded cross index %s\n"), filename); GetLogger()->info(_("Loaded cross index {}\n"), filename);
} }
} }
} }
@ -4123,11 +4125,11 @@ bool CelestiaCore::readStars(const CelestiaConfig& cfg,
{ {
starNameDB = StarNameDatabase::readNames(starNamesFile); starNameDB = StarNameDatabase::readNames(starNamesFile);
if (starNameDB == nullptr) if (starNameDB == nullptr)
cerr << _("Error reading star names file\n"); GetLogger()->error(_("Error reading star names file\n"));
} }
else else
{ {
cerr << fmt::sprintf(_("Error opening %s\n"), cfg.starNamesFile); GetLogger()->error(_("Error opening {}\n"), cfg.starNamesFile);
} }
// First load the binary star database file. The majority of stars // First load the binary star database file. The majority of stars
@ -4141,7 +4143,7 @@ bool CelestiaCore::readStars(const CelestiaConfig& cfg,
ifstream starFile(cfg.starDatabaseFile.string(), ios::in | ios::binary); ifstream starFile(cfg.starDatabaseFile.string(), ios::in | ios::binary);
if (!starFile.good()) if (!starFile.good())
{ {
cerr << fmt::sprintf(_("Error opening %s\n"), cfg.starDatabaseFile); GetLogger()->error(_("Error opening {}\n"), cfg.starDatabaseFile);
delete starDB; delete starDB;
delete starNameDB; delete starNameDB;
return false; return false;
@ -4149,7 +4151,7 @@ bool CelestiaCore::readStars(const CelestiaConfig& cfg,
if (!starDB->loadBinary(starFile)) if (!starDB->loadBinary(starFile))
{ {
cerr << _("Error reading stars file\n"); GetLogger()->error(_("Error reading stars file\n"));
delete starDB; delete starDB;
delete starNameDB; delete starNameDB;
return false; return false;
@ -4175,7 +4177,7 @@ bool CelestiaCore::readStars(const CelestiaConfig& cfg,
if (starFile.good()) if (starFile.good())
starDB->load(starFile); starDB->load(starFile);
else else
cerr << fmt::sprintf(_("Error opening star catalog %s\n"), file); GetLogger()->error(_("Error opening star catalog {}\n"), file);
} }
// Now, read supplemental star files from the extras directories // Now, read supplemental star files from the extras directories
@ -4235,13 +4237,17 @@ void CelestiaCore::setFaintestAutoMag()
void CelestiaCore::fatalError(const string& msg, bool visual) void CelestiaCore::fatalError(const string& msg, bool visual)
{ {
if (alerter == nullptr) if (alerter == nullptr)
{
if (visual) if (visual)
flash(msg); flash(msg);
else else
cerr << msg; GetLogger()->error(msg.c_str());
}
else else
{
alerter->fatalError(msg); alerter->fatalError(msg);
} }
}
void CelestiaCore::setAlerter(Alerter* a) void CelestiaCore::setAlerter(Alerter* a)
{ {
@ -4758,7 +4764,7 @@ Image CelestiaCore::captureImage() const
viewport[2], viewport[3], viewport[2], viewport[3],
format, image.getPixels())) format, image.getPixels()))
{ {
fmt::print(cerr, _("Unable to capture a frame!\n")); GetLogger()->error(_("Unable to capture a frame!\n"));
} }
return image; return image;
} }
@ -4770,7 +4776,7 @@ bool CelestiaCore::saveScreenShot(const fs::path& filename, ContentType type) co
if (type != Content_JPEG && type != Content_PNG) if (type != Content_JPEG && type != Content_PNG)
{ {
fmt::print(cerr, _("Unsupported image type: {}!\n"), filename); GetLogger()->error(_("Unsupported image type: {}!\n"), filename);
return false; return false;
} }
@ -4815,6 +4821,6 @@ void CelestiaCore::setLogFile(const fs::path &fn)
} }
else else
{ {
fmt::print(cerr, "Unable to open log file {}\n", fn); GetLogger()->error("Unable to open log file {}\n", fn);
} }
} }

View File

@ -11,7 +11,7 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <cassert> #include <cassert>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/fsutils.h> #include <celutil/fsutils.h>
#include <celengine/texmanager.h> #include <celengine/texmanager.h>
#include <celutil/tokenizer.h> #include <celutil/tokenizer.h>
@ -37,7 +37,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
ifstream configFile(filename.string()); ifstream configFile(filename.string());
if (!configFile.good()) if (!configFile.good())
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error opening config file '%s'.\n", filename); GetLogger()->error("Error opening config file '{}'.\n", filename);
return config; return config;
} }
@ -46,14 +46,14 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
if (tokenizer.nextToken() != Tokenizer::TokenName) if (tokenizer.nextToken() != Tokenizer::TokenName)
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s:%d 'Configuration' expected.\n", filename, GetLogger()->error("{}:{} 'Configuration' expected.\n", filename,
tokenizer.getLineNumber()); tokenizer.getLineNumber());
return config; return config;
} }
if (tokenizer.getStringValue() != "Configuration") if (tokenizer.getStringValue() != "Configuration")
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s:%d 'Configuration' expected.\n", filename, GetLogger()->error("{}:{} 'Configuration' expected.\n", filename,
tokenizer.getLineNumber()); tokenizer.getLineNumber());
return config; return config;
} }
@ -61,7 +61,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
Value* configParamsValue = parser.readValue(); Value* configParamsValue = parser.readValue();
if (configParamsValue == nullptr || configParamsValue->getType() != Value::HashType) if (configParamsValue == nullptr || configParamsValue->getType() != Value::HashType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: Bad configuration file.\n", filename); GetLogger()->error("{}: Bad configuration file.\n", filename);
return config; return config;
} }
@ -141,7 +141,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
{ {
if (solarSystemsVal->getType() != Value::ArrayType) if (solarSystemsVal->getType() != Value::ArrayType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: SolarSystemCatalogs must be an array.\n", filename); GetLogger()->error("{}: SolarSystemCatalogs must be an array.\n", filename);
} }
else else
{ {
@ -157,7 +157,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
} }
else else
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: Solar system catalog name must be a string.\n", filename); GetLogger()->error("{}: Solar system catalog name must be a string.\n", filename);
} }
} }
} }
@ -168,7 +168,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
{ {
if (starCatalogsVal->getType() != Value::ArrayType) if (starCatalogsVal->getType() != Value::ArrayType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: StarCatalogs must be an array.\n", filename); GetLogger()->error("{}: StarCatalogs must be an array.\n", filename);
} }
else else
{ {
@ -185,7 +185,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
} }
else else
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: Star catalog name must be a string.\n", filename); GetLogger()->error("{}: Star catalog name must be a string.\n", filename);
} }
} }
} }
@ -196,7 +196,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
{ {
if (dsoCatalogsVal->getType() != Value::ArrayType) if (dsoCatalogsVal->getType() != Value::ArrayType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: DeepSkyCatalogs must be an array.\n", filename); GetLogger()->error("{}: DeepSkyCatalogs must be an array.\n", filename);
} }
else else
{ {
@ -213,7 +213,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
} }
else else
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: DeepSky catalog name must be a string.\n", filename); GetLogger()->error("{}: DeepSky catalog name must be a string.\n", filename);
} }
} }
} }
@ -235,7 +235,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
} }
else else
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: Extras directory name must be a string.\n", filename); GetLogger()->error("{}: Extras directory name must be a string.\n", filename);
} }
} }
} }
@ -245,7 +245,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
} }
else else
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: ExtrasDirectories must be an array or a string.\n", filename); GetLogger()->error("{}: ExtrasDirectories must be an array or a string.\n", filename);
} }
} }
@ -265,7 +265,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
} }
else else
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: Skipped file name must be a string.\n", filename); GetLogger()->error("{}: Skipped file name must be a string.\n", filename);
} }
} }
} }
@ -275,7 +275,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
} }
else else
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: SkipExtras must be an array or a string.\n", filename); GetLogger()->error("{}: SkipExtras must be an array or a string.\n", filename);
} }
} }
@ -284,7 +284,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
{ {
if (ignoreExtVal->getType() != Value::ArrayType) if (ignoreExtVal->getType() != Value::ArrayType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: IgnoreGLExtensions must be an array.\n", filename); GetLogger()->error("{}: IgnoreGLExtensions must be an array.\n", filename);
} }
else else
{ {
@ -298,7 +298,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
} }
else else
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: extension name must be a string.\n", filename); GetLogger()->error("{}: extension name must be a string.\n", filename);
} }
} }
} }
@ -309,7 +309,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con
{ {
if (starTexValue->getType() != Value::HashType) if (starTexValue->getType() != Value::HashType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "%s: StarTextures must be a property list.\n", filename); GetLogger()->error("{}: StarTextures must be a property list.\n", filename);
} }
else else
{ {

View File

@ -9,7 +9,7 @@
#include <config.h> #include <config.h>
#include <algorithm> #include <algorithm>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/stringutils.h> #include <celutil/stringutils.h>
#include <celengine/astro.h> #include <celengine/astro.h>
#include <celengine/parser.h> #include <celengine/parser.h>
@ -17,7 +17,7 @@
#include "destination.h" #include "destination.h"
using namespace std; using namespace std;
using celestia::util::GetLogger;
DestinationList* ReadDestinationList(istream& in) DestinationList* ReadDestinationList(istream& in)
{ {
@ -29,7 +29,7 @@ DestinationList* ReadDestinationList(istream& in)
{ {
if (tokenizer.getTokenType() != Tokenizer::TokenBeginGroup) if (tokenizer.getTokenType() != Tokenizer::TokenBeginGroup)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error parsing destinations file.\n"); GetLogger()->error("Error parsing destinations file.\n");
for_each(destinations->begin(), destinations->end(), [](Destination* dest) { delete dest; }); for_each(destinations->begin(), destinations->end(), [](Destination* dest) { delete dest; });
delete destinations; delete destinations;
return nullptr; return nullptr;
@ -39,7 +39,7 @@ DestinationList* ReadDestinationList(istream& in)
Value* destValue = parser.readValue(); Value* destValue = parser.readValue();
if (destValue == nullptr || destValue->getType() != Value::HashType) if (destValue == nullptr || destValue->getType() != Value::HashType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error parsing destination.\n"); GetLogger()->error("Error parsing destination.\n");
for_each(destinations->begin(), destinations->end(), [](Destination* dest) { delete dest; }); for_each(destinations->begin(), destinations->end(), [](Destination* dest) { delete dest; });
delete destinations; delete destinations;
if (destValue != nullptr) if (destValue != nullptr)
@ -52,7 +52,7 @@ DestinationList* ReadDestinationList(istream& in)
if (!destParams->getString("Name", dest->name)) if (!destParams->getString("Name", dest->name))
{ {
DPRINTF(LOG_LEVEL_INFO, "Skipping unnamed destination\n"); GetLogger()->warn("Skipping unnamed destination\n");
delete dest; delete dest;
} }
else else

View File

@ -13,12 +13,12 @@
#include <iomanip> #include <iomanip>
#include <celengine/parser.h> #include <celengine/parser.h>
#include <celutil/tokenizer.h> #include <celutil/tokenizer.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include "favorites.h" #include "favorites.h"
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using celestia::util::GetLogger;
FavoritesList* ReadFavoritesList(istream& in) FavoritesList* ReadFavoritesList(istream& in)
{ {
@ -30,7 +30,7 @@ FavoritesList* ReadFavoritesList(istream& in)
{ {
if (tokenizer.getTokenType() != Tokenizer::TokenString) if (tokenizer.getTokenType() != Tokenizer::TokenString)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error parsing favorites file.\n"); GetLogger()->error("Error parsing favorites file.\n");
for_each(favorites->begin(), favorites->end(), [](FavoritesEntry* fav) { delete fav; }); for_each(favorites->begin(), favorites->end(), [](FavoritesEntry* fav) { delete fav; });
delete favorites; delete favorites;
return nullptr; return nullptr;
@ -42,7 +42,7 @@ FavoritesList* ReadFavoritesList(istream& in)
Value* favParamsValue = parser.readValue(); Value* favParamsValue = parser.readValue();
if (favParamsValue == nullptr || favParamsValue->getType() != Value::HashType) if (favParamsValue == nullptr || favParamsValue->getType() != Value::HashType)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error parsing favorites entry %s\n", fav->name.c_str()); GetLogger()->error("Error parsing favorites entry {}\n", fav->name);
for_each(favorites->begin(), favorites->end(), [](FavoritesEntry* fav) { delete fav; }); for_each(favorites->begin(), favorites->end(), [](FavoritesEntry* fav) { delete fav; });
delete favorites; delete favorites;
if (favParamsValue != nullptr) if (favParamsValue != nullptr)

View File

@ -29,7 +29,7 @@
#endif #endif
#include <fmt/printf.h> #include <fmt/printf.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/tzutil.h> #include <celutil/tzutil.h>
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celengine/astro.h> #include <celengine/astro.h>
@ -40,6 +40,7 @@
using namespace celestia; using namespace celestia;
using namespace std; using namespace std;
using celestia::util::GetLogger;
char AppName[] = "Celestia"; char AppName[] = "Celestia";
@ -464,31 +465,32 @@ int main(int argc, char* argv[])
ready = false; ready = false;
char c; char c;
int startfile = 0; const char* startfile = nullptr;
while ((c = getopt(argc, argv, "v::f")) > -1) Level verbosity = Level::Info;
while ((c = getopt(argc, argv, "vdf:")) > -1)
{ {
switch (c) switch (c)
{ {
case '?': case '?':
cout << "Usage: celestia [-v] [-f <filename>]\n"; cout << "Usage: celestia [-v] [-d] [-f <filename>]\n";
exit(1); exit(1);
case 'v': case 'v':
if(optarg) verbosity = Level::Verbose;
SetDebugVerbosity(atoi(optarg));
else
SetDebugVerbosity(0);
break; break;
case 'd':
verbosity = Level::Debug;
case 'f': case 'f':
startfile = 1; if (optarg == nullptr)
{
cerr << "Missing Filename.\n";
return 1;
}
startfile = optarg;
} }
} }
appCore = new CelestiaCore(); appCore = new CelestiaCore();
if (appCore == nullptr) GetLogger()->setLevel(verbosity);
{
cerr << "Out of memory.\n";
return 1;
}
if (!appCore->initSimulation()) if (!appCore->initSimulation())
{ {
@ -519,7 +521,7 @@ int main(int argc, char* argv[])
if (!gl::init(appCore->getConfig()->ignoreGLExtensions) || !gl::checkVersion(gl::GL_2_1)) if (!gl::init(appCore->getConfig()->ignoreGLExtensions) || !gl::checkVersion(gl::GL_2_1))
{ {
cout << _("Celestia was unable to initialize OpenGL 2.1.\n"); cerr << _("Celestia was unable to initialize OpenGL 2.1.\n");
return 1; return 1;
} }
@ -540,14 +542,9 @@ int main(int argc, char* argv[])
appCore->setTimeZoneBias(dstBias); appCore->setTimeZoneBias(dstBias);
} }
if (startfile == 1) { if (startfile != nullptr) {
if (argv[argc - 1][0] == '-') { cout << "*** Using CEL File: " << startfile << endl;
cout << "Missing Filename.\n"; appCore->runScript(startfile);
return 1;
}
cout << "*** Using CEL File: " << argv[argc - 1] << endl;
appCore->runScript(argv[argc - 1]);
} }
ready = true; ready = true;

View File

@ -12,8 +12,6 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <celutil/debug.h>
#include "dialog-options.h" #include "dialog-options.h"
#include "common.h" #include "common.h"
#include "ui.h" #include "ui.h"

View File

@ -36,7 +36,6 @@
#include <celengine/glsupport.h> #include <celengine/glsupport.h>
#include <celengine/simulation.h> #include <celengine/simulation.h>
#include <celestia/celestiacore.h> #include <celestia/celestiacore.h>
#include <celutil/debug.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
/* Includes for the GNOME front-end */ /* Includes for the GNOME front-end */
@ -381,14 +380,7 @@ int main(int argc, char* argv[])
SplashData* ss = splashStart(app, !noSplash); SplashData* ss = splashStart(app, !noSplash);
splashSetText(ss, "Initializing..."); splashSetText(ss, "Initializing...");
SetDebugVerbosity(0);
app->core = new CelestiaCore(); app->core = new CelestiaCore();
if (app->core == NULL)
{
cerr << "Failed to initialize Celestia core.\n";
return 1;
}
app->renderer = app->core->getRenderer(); app->renderer = app->core->getRenderer();
g_assert(app->renderer); g_assert(app->renderer);

View File

@ -32,7 +32,6 @@
#include "celengine/astro.h" #include "celengine/astro.h"
#include "celutil/filetype.h" #include "celutil/filetype.h"
#include "celutil/debug.h"
#include "celutil/gettext.h" #include "celutil/gettext.h"
#include "celestia/celestiacore.h" #include "celestia/celestiacore.h"
#include "celengine/simulation.h" #include "celengine/simulation.h"

View File

@ -14,6 +14,7 @@
#include <celestia/celestiacore.h> #include <celestia/celestiacore.h>
#include <celengine/astro.h> #include <celengine/astro.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/logger.h>
#include <celutil/utf8.h> #include <celutil/utf8.h>
#include <celengine/universe.h> #include <celengine/universe.h>
#include <QTextBrowser> #include <QTextBrowser>
@ -24,6 +25,7 @@
using namespace std; using namespace std;
using namespace Eigen; using namespace Eigen;
using namespace celmath; using namespace celmath;
using celestia::util::GetLogger;
// TODO: This should be moved to astro.cpp // TODO: This should be moved to astro.cpp
struct OrbitalElements struct OrbitalElements
@ -431,10 +433,10 @@ static void CalculateOsculatingElements(const Orbit& orbit,
double beginTime = 0.0; double beginTime = 0.0;
double endTime = 0.0; double endTime = 0.0;
orbit.getValidRange(beginTime, endTime); orbit.getValidRange(beginTime, endTime);
clog << "t+dt: " << t + dt << ", endTime: " << endTime << endl; GetLogger()->debug("t+dt: {}, endTime: {}\n", t + dt, endTime);
if (t + dt > endTime) if (t + dt > endTime)
{ {
clog << "REVERSE\n"; GetLogger()->debug("REVERSE\n");
sdt = -dt; sdt = -dt;
} }
} }
@ -448,9 +450,9 @@ static void CalculateOsculatingElements(const Orbit& orbit,
Vector3d r = p0; Vector3d r = p0;
double GM = accel * r.squaredNorm(); double GM = accel * r.squaredNorm();
clog << "vel: " << v0.norm() / 86400.0 << endl; GetLogger()->debug("vel: {}\n", v0.norm() / 86400.0);
clog << "vel (est): " << (p1 - p0).norm() / sdt / 86400 << endl; GetLogger()->debug("vel (est): {}\n", (p1 - p0).norm() / sdt / 86400);
clog << "osc: " << t << ", " << dt << ", " << accel << ", GM=" << GM << endl; GetLogger()->debug("osc: {}, {}, {}, GM={}\n", t, dt, accel, GM);
StateVectorToElements(p0, v0, GM, elements); StateVectorToElements(p0, v0, GM, elements);
} }

View File

@ -11,15 +11,14 @@
#include "scriptmenu.h" #include "scriptmenu.h"
#include <iostream> #include <iostream>
#include <fmt/printf.h>
#include <fmt/ostream.h>
#include <celcompat/filesystem.h> #include <celcompat/filesystem.h>
#include <celutil/filetype.h> #include <celutil/filetype.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/logger.h>
#include <fstream> #include <fstream>
using namespace std; using namespace std;
using celestia::util::GetLogger;
static const char TitleTag[] = "Title:"; static const char TitleTag[] = "Title:";
@ -85,7 +84,7 @@ ScanScriptsDirectory(const fs::path& scriptsDir, bool deep)
std::error_code ec; std::error_code ec;
if (!fs::is_directory(scriptsDir, ec)) if (!fs::is_directory(scriptsDir, ec))
{ {
cerr << fmt::sprintf(_("Path %s doesn't exist or isn't a directory\n"), scriptsDir); GetLogger()->warn(_("Path {} doesn't exist or isn't a directory\n"), scriptsDir);
return scripts; return scripts;
} }

View File

@ -14,10 +14,12 @@
#include <celcompat/charconv.h> #include <celcompat/charconv.h>
#include <celutil/bigfix.h> #include <celutil/bigfix.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/logger.h>
#include <celutil/stringutils.h> #include <celutil/stringutils.h>
#include "celestiacore.h" #include "celestiacore.h"
#include "url.h" #include "url.h"
using celestia::util::GetLogger;
namespace namespace
{ {
@ -309,7 +311,7 @@ Url::decodeString(celestia::compat::string_view str)
} }
else else
{ {
fmt::print(std::cerr, _("Incorrect hex value \"{}\"\n"), c_code); GetLogger()->warn(_("Incorrect hex value \"{}\"\n"), c_code);
out += '%'; out += '%';
out.append(c_code.data(), c_code.length()); out.append(c_code.data(), c_code.length());
} }
@ -392,7 +394,7 @@ bool Url::parse(celestia::compat::string_view urlStr)
// proper URL string must start with protocol (cel://) // proper URL string must start with protocol (cel://)
if (urlStr.compare(0, Url::proto().length(), Url::proto()) != 0) if (urlStr.compare(0, Url::proto().length(), Url::proto()) != 0)
{ {
std::cerr << fmt::sprintf(_("URL must start with \"%s\"!\n"), Url::proto()); GetLogger()->error(_("URL must start with \"{}\"!\n"), Url::proto());
return false; return false;
} }
@ -408,7 +410,7 @@ bool Url::parse(celestia::compat::string_view urlStr)
pos = pathStr.find('/'); pos = pathStr.find('/');
if (pos == npos) if (pos == npos)
{ {
std::cerr << _("URL must have at least mode and time!\n"); GetLogger()->error(_("URL must have at least mode and time!\n"));
return false; return false;
} }
auto modeStr = pathStr.substr(0, pos); auto modeStr = pathStr.substr(0, pos);
@ -419,7 +421,7 @@ bool Url::parse(celestia::compat::string_view urlStr)
auto it = std::find_if(std::begin(modes), std::end(modes), lambda); auto it = std::find_if(std::begin(modes), std::end(modes), lambda);
if (it == std::end(modes)) if (it == std::end(modes))
{ {
std::cerr << fmt::sprintf(_("Unsupported URL mode \"%s\"!\n"), modeStr); GetLogger()->error(_("Unsupported URL mode \"{}\"!\n"), modeStr);
return false; return false;
} }
state.m_coordSys = it->mode; state.m_coordSys = it->mode;
@ -437,7 +439,7 @@ bool Url::parse(celestia::compat::string_view urlStr)
{ {
if (pos != npos) if (pos != npos)
{ {
std::cerr << _("URL must contain only one body\n"); GetLogger()->error(_("URL must contain only one body\n"));
return false; return false;
} }
auto body = Url::decodeString(bodiesStr); auto body = Url::decodeString(bodiesStr);
@ -449,7 +451,7 @@ bool Url::parse(celestia::compat::string_view urlStr)
{ {
if (pos == npos || bodiesStr.find('/', pos + 1) != npos) if (pos == npos || bodiesStr.find('/', pos + 1) != npos)
{ {
std::cerr << _("URL must contain 2 bodies\n"); GetLogger()->error(_("URL must contain 2 bodies\n"));
return false; return false;
} }
auto body = Url::decodeString(bodiesStr.substr(0, pos)); auto body = Url::decodeString(bodiesStr.substr(0, pos));
@ -490,14 +492,14 @@ bool Url::parse(celestia::compat::string_view urlStr)
auto &p = params["ver"]; auto &p = params["ver"];
if (!to_number(p, version)) if (!to_number(p, version))
{ {
std::cerr << fmt::sprintf(_("Invalid URL version \"%s\"!\n"), p); GetLogger()->error(_("Invalid URL version \"{}\"!\n"), p);
return false; return false;
} }
} }
if (version != 3 && version != 4) if (version != 3 && version != 4)
{ {
std::cerr << fmt::sprintf(_("Unsupported URL version: %i\n"), version); GetLogger()->error(_("Unsupported URL version: {}\n"), version);
return false; return false;
} }
@ -529,7 +531,7 @@ auto ParseURLParams(celestia::compat::string_view paramsStr)
auto vpos = kv.find('='); auto vpos = kv.find('=');
if (vpos == npos) if (vpos == npos)
{ {
std::cerr << _("URL parameter must look like key=value\n"); GetLogger()->error(_("URL parameter must look like key=value\n"));
break; break;
} }
params[kv.substr(0, vpos)] = Url::decodeString(kv.substr(vpos + 1)); params[kv.substr(0, vpos)] = Url::decodeString(kv.substr(vpos + 1));

View File

@ -11,9 +11,11 @@
#include <celengine/render.h> #include <celengine/render.h>
#include <celengine/framebuffer.h> #include <celengine/framebuffer.h>
#include <celutil/color.h> #include <celutil/color.h>
#include <celutil/logger.h>
#include "view.h" #include "view.h"
using namespace std; using namespace std;
using celestia::util::GetLogger;
View::View(View::Type _type, View::View(View::Type _type,
Renderer *_renderer, Renderer *_renderer,
@ -271,7 +273,7 @@ void View::updateFBO(int gWidth, int gHeight)
FramebufferObject::ColorAttachment | FramebufferObject::DepthAttachment)); FramebufferObject::ColorAttachment | FramebufferObject::DepthAttachment));
if (!fbo->isValid()) if (!fbo->isValid())
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error creating view FBO.\n"); GetLogger()->error("Error creating view FBO.\n");
fbo = nullptr; fbo = nullptr;
} }
} }

View File

@ -11,10 +11,12 @@
#include "winbookmarks.h" #include "winbookmarks.h"
#include "res/resource.h" #include "res/resource.h"
#include <celutil/logger.h>
#include <celutil/winutil.h> #include <celutil/winutil.h>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
using celestia::util::GetLogger;
bool dragging; bool dragging;
HTREEITEM hDragItem; HTREEITEM hDragItem;
@ -295,7 +297,7 @@ void BuildFavoritesMenu(HMENU menuBar,
if (!child->isFolder && if (!child->isFolder &&
child->parentFolder == folderName) child->parentFolder == folderName)
{ {
clog << " " << child->name << '\n'; GetLogger()->debug(" {}\n", child->name);
// Add item to sub menu // Add item to sub menu
menuInfo.cbSize = sizeof(MENUITEMINFO); menuInfo.cbSize = sizeof(MENUITEMINFO);
menuInfo.fMask = MIIM_TYPE | MIIM_ID; menuInfo.fMask = MIIM_TYPE | MIIM_ID;

View File

@ -31,12 +31,12 @@
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celutil/array_view.h> #include <celutil/array_view.h>
#include <celutil/debug.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/fsutils.h> #include <celutil/fsutils.h>
#include <celutil/winutil.h> #include <celutil/winutil.h>
#include <celutil/tzutil.h> #include <celutil/tzutil.h>
#include <celutil/filetype.h> #include <celutil/filetype.h>
#include <celutil/logger.h>
#include <celengine/astro.h> #include <celengine/astro.h>
#include <celscript/legacy/cmdparser.h> #include <celscript/legacy/cmdparser.h>
@ -170,7 +170,9 @@ static LRESULT CALLBACK MainWindowProc(HWND hWnd,
#define MENU_CHOOSE_SURFACE 31000 #define MENU_CHOOSE_SURFACE 31000
bool ignoreOldFavorites = false; static bool ignoreOldFavorites = false;
static Level verbosity = Level::Info;
struct AppPreferences struct AppPreferences
{ {
@ -2766,7 +2768,10 @@ static void HandleCaptureMovie(HWND hWnd)
if (nFileType != 1) if (nFileType != 1)
{ {
// Invalid file extension specified. // Invalid file extension specified.
DPRINTF(0, "Unknown file extension specified for movie capture.\n"); MessageBox(hWnd,
_("Unknown file extension specified for movie capture."),
_("Error"),
MB_OK | MB_ICONERROR);
} }
else else
{ {
@ -2996,7 +3001,11 @@ static bool parseCommandLine(int argc, char* argv[])
bool isLastArg = (i == argc - 1); bool isLastArg = (i == argc - 1);
if (strcmp(argv[i], "--verbose") == 0) if (strcmp(argv[i], "--verbose") == 0)
{ {
SetDebugVerbosity(1); verbosity = Level::Verbose;
}
else if (strcmp(argv[i], "--debug") == 0)
{
verbosity = Level::Debug;
} }
else if (strcmp(argv[i], "--fullscreen") == 0) else if (strcmp(argv[i], "--fullscreen") == 0)
{ {
@ -3233,6 +3242,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
} }
appCore = new CelestiaCore(); appCore = new CelestiaCore();
GetLogger()->setLevel(verbosity);
// Gettext integration // Gettext integration
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");

View File

@ -9,13 +9,14 @@
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <celengine/image.h> #include <celengine/image.h>
#include <celutil/debug.h> #include <celutil/logger.h>
extern "C" { extern "C" {
#include <avif/avif.h> #include <avif/avif.h>
} }
using celestia::PixelFormat; using celestia::PixelFormat;
using celestia::util::GetLogger;
Image* LoadAVIFImage(const fs::path& filename) Image* LoadAVIFImage(const fs::path& filename)
{ {
@ -23,7 +24,7 @@ Image* LoadAVIFImage(const fs::path& filename)
avifResult result = avifDecoderSetIOFile(decoder, filename.string().c_str()); avifResult result = avifDecoderSetIOFile(decoder, filename.string().c_str());
if (result != AVIF_RESULT_OK) if (result != AVIF_RESULT_OK)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Cannot open file for read: '%s'\n", filename); GetLogger()->error("Cannot open file for read: '{}'\n", filename);
avifDecoderDestroy(decoder); avifDecoderDestroy(decoder);
return nullptr; return nullptr;
} }
@ -31,14 +32,14 @@ Image* LoadAVIFImage(const fs::path& filename)
result = avifDecoderParse(decoder); result = avifDecoderParse(decoder);
if (result != AVIF_RESULT_OK) if (result != AVIF_RESULT_OK)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Failed to decode image: %s\n", avifResultToString(result)); GetLogger()->error("Failed to decode image: {}\n", avifResultToString(result));
avifDecoderDestroy(decoder); avifDecoderDestroy(decoder);
return nullptr; return nullptr;
} }
if (avifDecoderNextImage(decoder) != AVIF_RESULT_OK) if (avifDecoderNextImage(decoder) != AVIF_RESULT_OK)
{ {
DPRINTF(LOG_LEVEL_ERROR, "No image available: %s\n", filename); GetLogger()->error("No image available: {}\n", filename);
avifDecoderDestroy(decoder); avifDecoderDestroy(decoder);
return nullptr; return nullptr;
} }
@ -53,7 +54,7 @@ Image* LoadAVIFImage(const fs::path& filename)
if (avifImageYUVToRGB(decoder->image, &rgb) != AVIF_RESULT_OK) if (avifImageYUVToRGB(decoder->image, &rgb) != AVIF_RESULT_OK)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Conversion from YUV failed: %s\n", filename); GetLogger()->error("Conversion from YUV failed: {}\n", filename);
delete image; delete image;
avifDecoderDestroy(decoder); avifDecoderDestroy(decoder);
return nullptr; return nullptr;

View File

@ -16,9 +16,10 @@
#include <celengine/image.h> #include <celengine/image.h>
#include <celutil/binaryread.h> #include <celutil/binaryread.h>
#include <celutil/debug.h> #include <celutil/logger.h>
namespace celutil = celestia::util; namespace celutil = celestia::util;
using celestia::util::GetLogger;
namespace namespace
{ {
@ -84,7 +85,7 @@ Image* LoadBMPImage(std::istream& in)
std::vector<uint8_t> palette; std::vector<uint8_t> palette;
if (imageHeader.bpp == 8) if (imageHeader.bpp == 8)
{ {
DPRINTF(LOG_LEVEL_DEBUG, "Reading %u color palette\n", imageHeader.colorsUsed); GetLogger()->debug("Reading {} color palette\n", imageHeader.colorsUsed);
palette.resize(imageHeader.colorsUsed * 4); palette.resize(imageHeader.colorsUsed * 4);
if (!in.read(reinterpret_cast<char*>(palette.data()), imageHeader.colorsUsed * 4).good()) if (!in.read(reinterpret_cast<char*>(palette.data()), imageHeader.colorsUsed * 4).good())
{ {

View File

@ -15,12 +15,13 @@
#include <memory> #include <memory>
#include <celengine/glsupport.h> #include <celengine/glsupport.h>
#include <celengine/image.h> #include <celengine/image.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/bytes.h> #include <celutil/bytes.h>
#include "dds_decompress.h" #include "dds_decompress.h"
using namespace celestia; using namespace celestia;
using namespace std; using namespace std;
using celestia::util::GetLogger;
struct DDPixelFormat struct DDPixelFormat
@ -139,7 +140,7 @@ Image* LoadDDSImage(const fs::path& filename)
ifstream in(filename.string(), ios::in | ios::binary); ifstream in(filename.string(), ios::in | ios::binary);
if (!in.good()) if (!in.good())
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error opening DDS texture file %s.\n", filename); GetLogger()->error("Error opening DDS texture file {}.\n", filename);
return nullptr; return nullptr;
} }
@ -148,14 +149,14 @@ Image* LoadDDSImage(const fs::path& filename)
|| header[0] != 'D' || header[1] != 'D' || header[0] != 'D' || header[1] != 'D'
|| header[2] != 'S' || header[3] != ' ') || header[2] != 'S' || header[3] != ' ')
{ {
DPRINTF(LOG_LEVEL_ERROR, "DDS texture file %s has bad header.\n", filename); GetLogger()->error("DDS texture file {} has bad header.\n", filename);
return nullptr; return nullptr;
} }
DDSurfaceDesc ddsd; DDSurfaceDesc ddsd;
if (!in.read(reinterpret_cast<char*>(&ddsd), sizeof ddsd).good()) if (!in.read(reinterpret_cast<char*>(&ddsd), sizeof ddsd).good())
{ {
DPRINTF(LOG_LEVEL_ERROR, "DDS file %s has bad surface desc.\n", filename); GetLogger()->error("DDS file {} has bad surface desc.\n", filename);
return nullptr; return nullptr;
} }
LE_TO_CPU_INT32(ddsd.size, ddsd.size); LE_TO_CPU_INT32(ddsd.size, ddsd.size);
@ -189,12 +190,12 @@ Image* LoadDDSImage(const fs::path& filename)
} }
else else
{ {
cerr << "Unknown FourCC in DDS file: " << ddsd.format.fourCC; GetLogger()->error("Unknown FourCC in DDS file: {}\n", ddsd.format.fourCC);
} }
} }
else else
{ {
clog << "DDS Format: " << ddsd.format.fourCC << '\n'; GetLogger()->debug("DDS Format: {}\n", ddsd.format.fourCC);
if (ddsd.format.bpp == 32) if (ddsd.format.bpp == 32)
{ {
if (ddsd.format.redMask == 0x00ff0000 && if (ddsd.format.redMask == 0x00ff0000 &&
@ -233,7 +234,7 @@ Image* LoadDDSImage(const fs::path& filename)
if (format == -1) if (format == -1)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Unsupported format for DDS texture file %s.\n", filename); GetLogger()->error("Unsupported format for DDS texture file {}.\n", filename);
return nullptr; return nullptr;
} }
@ -268,7 +269,7 @@ Image* LoadDDSImage(const fs::path& filename)
if (pixels == nullptr) if (pixels == nullptr)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Failed to decompress DDS texture file %s.\n", filename); GetLogger()->error("Failed to decompress DDS texture file {}.\n", filename);
return nullptr; return nullptr;
} }
@ -302,7 +303,7 @@ Image* LoadDDSImage(const fs::path& filename)
in.read(reinterpret_cast<char*>(img->getPixels()), img->getSize()); in.read(reinterpret_cast<char*>(img->getPixels()), img->getSize());
if (!in.eof() && !in.good()) if (!in.eof() && !in.good())
{ {
DPRINTF(LOG_LEVEL_ERROR, "Failed reading data from DDS texture file %s.\n", filename); GetLogger()->error("Failed reading data from DDS texture file {}.\n", filename);
delete img; delete img;
return nullptr; return nullptr;
} }

View File

@ -15,9 +15,10 @@ extern "C" {
#include <jpeglib.h> #include <jpeglib.h>
} }
#include <celengine/image.h> #include <celengine/image.h>
#include <celutil/debug.h> #include <celutil/logger.h>
using celestia::PixelFormat; using celestia::PixelFormat;
using celestia::util::GetLogger;
namespace namespace
{ {
@ -190,7 +191,7 @@ bool SaveJPEGImage(const fs::path& filename,
#endif #endif
if (out == nullptr) if (out == nullptr)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Can't open screen capture file '%s'\n", filename); GetLogger()->error("Can't open screen capture file '{}'\n", filename);
return false; return false;
} }

View File

@ -11,15 +11,12 @@
#include <iostream> #include <iostream>
#include <png.h> #include <png.h>
#include <zlib.h> #include <zlib.h>
#include <fmt/ostream.h>
#include <fmt/printf.h>
#include <celengine/image.h> #include <celengine/image.h>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
using std::cerr;
using std::clog;
using celestia::PixelFormat; using celestia::PixelFormat;
using celestia::util::GetLogger;
namespace namespace
{ {
@ -27,7 +24,7 @@ void PNGReadData(png_structp png_ptr, png_bytep data, png_size_t length)
{ {
auto* fp = (FILE*) png_get_io_ptr(png_ptr); auto* fp = (FILE*) png_get_io_ptr(png_ptr);
if (fread((void*) data, 1, length, fp) != length) if (fread((void*) data, 1, length, fp) != length)
cerr << "Error reading PNG data"; GetLogger()->error("Error reading PNG data");
} }
void PNGWriteData(png_structp png_ptr, png_bytep data, png_size_t length) void PNGWriteData(png_structp png_ptr, png_bytep data, png_size_t length)
@ -54,7 +51,7 @@ Image* LoadPNGImage(const fs::path& filename)
#endif #endif
if (fp == nullptr) if (fp == nullptr)
{ {
clog << fmt::sprintf(_("Error opening image file %s\n"), filename); GetLogger()->error(_("Error opening image file {}.\n"), filename);
return nullptr; return nullptr;
} }
@ -62,7 +59,7 @@ Image* LoadPNGImage(const fs::path& filename)
elements_read = fread(header, 1, sizeof(header), fp); elements_read = fread(header, 1, sizeof(header), fp);
if (elements_read == 0 || png_sig_cmp((unsigned char*) header, 0, sizeof(header))) if (elements_read == 0 || png_sig_cmp((unsigned char*) header, 0, sizeof(header)))
{ {
clog << fmt::sprintf(_("Error: %s is not a PNG file.\n"), filename); GetLogger()->error(_("Error: {} is not a PNG file.\n"), filename);
fclose(fp); fclose(fp);
return nullptr; return nullptr;
} }
@ -88,7 +85,7 @@ Image* LoadPNGImage(const fs::path& filename)
fclose(fp); fclose(fp);
delete img; delete img;
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) nullptr); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) nullptr);
clog << fmt::sprintf(_("Error reading PNG image file %s\n"), filename); GetLogger()->error(_("Error reading PNG image file {}\n"), filename);
return nullptr; return nullptr;
} }
@ -178,7 +175,7 @@ bool SavePNGImage(const fs::path& filename,
#endif #endif
if (out == nullptr) if (out == nullptr)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Can't open screen capture file '%s'\n", filename); GetLogger()->error(_("Can't open screen capture file '{}'\n"), filename);
return false; return false;
} }
@ -209,7 +206,7 @@ bool SavePNGImage(const fs::path& filename,
if (png_ptr == nullptr) if (png_ptr == nullptr)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Screen capture: error allocating png_ptr\n"); GetLogger()->error("Error allocating png_ptr\n");
fclose(out); fclose(out);
delete[] row_pointers; delete[] row_pointers;
return false; return false;
@ -218,7 +215,7 @@ bool SavePNGImage(const fs::path& filename,
info_ptr = png_create_info_struct(png_ptr); info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == nullptr) if (info_ptr == nullptr)
{ {
DPRINTF(LOG_LEVEL_ERROR, "Screen capture: error allocating info_ptr\n"); GetLogger()->error("Error allocating info_ptr\n");
fclose(out); fclose(out);
delete[] row_pointers; delete[] row_pointers;
png_destroy_write_struct(&png_ptr, (png_infopp) nullptr); png_destroy_write_struct(&png_ptr, (png_infopp) nullptr);
@ -227,7 +224,7 @@ bool SavePNGImage(const fs::path& filename,
if (setjmp(png_jmpbuf(png_ptr))) if (setjmp(png_jmpbuf(png_ptr)))
{ {
DPRINTF(LOG_LEVEL_ERROR, "Error writing PNG file '%s'\n", filename); GetLogger()->error(_("Error writing PNG file '{}'\n"), filename);
fclose(out); fclose(out);
delete[] row_pointers; delete[] row_pointers;
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);

View File

@ -20,6 +20,7 @@
#include <celutil/binaryread.h> #include <celutil/binaryread.h>
#include <celutil/binarywrite.h> #include <celutil/binarywrite.h>
#include <celutil/logger.h>
#include <celutil/tokenizer.h> #include <celutil/tokenizer.h>
#include "mesh.h" #include "mesh.h"
#include "model.h" #include "model.h"
@ -1905,7 +1906,7 @@ OpenModel(std::istream& in, HandleGetter& getHandle)
char header[CEL_MODEL_HEADER_LENGTH]; char header[CEL_MODEL_HEADER_LENGTH];
if (!in.read(header, CEL_MODEL_HEADER_LENGTH).good()) if (!in.read(header, CEL_MODEL_HEADER_LENGTH).good())
{ {
std::cerr << "Could not read model header\n"; celutil::GetLogger()->error("Could not read model header\n");
return nullptr; return nullptr;
} }
@ -1919,7 +1920,7 @@ OpenModel(std::istream& in, HandleGetter& getHandle)
} }
else else
{ {
std::cerr << "Model file has invalid header.\n"; celutil::GetLogger()->error("Model file has invalid header.\n");
return nullptr; return nullptr;
} }
} }
@ -1938,7 +1939,7 @@ LoadModel(std::istream& in, HandleGetter handleGetter)
std::unique_ptr<Model> model = loader->load(); std::unique_ptr<Model> model = loader->load();
if (model == nullptr) if (model == nullptr)
{ {
std::cerr << "Error in model file: " << loader->getErrorMessage() << '\n'; celutil::GetLogger()->error("Error in model file: {}\n", loader->getErrorMessage());
} }
return model; return model;

View File

@ -13,7 +13,7 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <Eigen/Geometry> #include <Eigen/Geometry>
#include <celutil/debug.h> #include <celutil/logger.h>
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <celengine/astro.h> #include <celengine/astro.h>
#include <celengine/parser.h> #include <celengine/parser.h>
@ -26,6 +26,7 @@
using namespace std; using namespace std;
using namespace celmath; using namespace celmath;
using namespace celestia::scripts; using namespace celestia::scripts;
using celestia::util::GetLogger;
static uint64_t parseRenderFlags(const string&, const FlagMap64&); static uint64_t parseRenderFlags(const string&, const FlagMap64&);
@ -872,7 +873,7 @@ uint64_t parseRenderFlags(const string &s, const FlagMap64& RenderFlagMap)
string name = tokenizer.getNameValue(); string name = tokenizer.getNameValue();
if (RenderFlagMap.count(name) == 0) if (RenderFlagMap.count(name) == 0)
cerr << "Unknown render flag: " << name << "\n"; GetLogger()->warn("Unknown render flag: {}\n", name);
else else
flags |= RenderFlagMap.at(name); flags |= RenderFlagMap.at(name);
@ -901,7 +902,7 @@ int parseLabelFlags(const string &s, const FlagMap &LabelFlagMap)
string name = tokenizer.getNameValue(); string name = tokenizer.getNameValue();
if (LabelFlagMap.count(name) == 0) if (LabelFlagMap.count(name) == 0)
cerr << "Unknown label flag: " << name << "\n"; GetLogger()->warn("Unknown label flag: {}\n", name);
else else
flags |= LabelFlagMap.at(name); flags |= LabelFlagMap.at(name);
@ -931,7 +932,7 @@ int parseOrbitFlags(const string &s, const FlagMap &BodyTypeMap)
name[0] = toupper(name[0]); name[0] = toupper(name[0]);
if (BodyTypeMap.count(name) == 0) if (BodyTypeMap.count(name) == 0)
cerr << "Unknown orbit flag: " << name << "\n"; GetLogger()->warn("Unknown orbit flag: {}\n", name);
else else
flags |= BodyTypeMap.at(name); flags |= BodyTypeMap.at(name);
@ -971,7 +972,7 @@ int parseConstellations(CommandConstellations* cmd, const string &s, int act)
} }
else else
{ {
DPRINTF(LOG_LEVEL_ERROR, "Command Parser: error parsing render flags\n"); GetLogger()->error("Command Parser: error parsing render flags\n");
return 0; return 0;
} }
} }
@ -1011,7 +1012,7 @@ int parseConstellationColor(CommandConstellationColor* cmd, const string &s, Eig
} }
else else
{ {
DPRINTF(LOG_LEVEL_ERROR, "Command Parser: error parsing render flags\n"); GetLogger()->error("Command Parser: error parsing render flags\n");
return 0; return 0;
} }
} }

View File

@ -17,6 +17,7 @@
#include <celestia/celestiacore.h> #include <celestia/celestiacore.h>
#include <celengine/multitexture.h> #include <celengine/multitexture.h>
#include <celutil/filetype.h> #include <celutil/filetype.h>
#include <celutil/logger.h>
#include <celmath/mathlib.h> #include <celmath/mathlib.h>
#include <iostream> #include <iostream>
#include <utility> #include <utility>
@ -26,6 +27,7 @@
using namespace std; using namespace std;
using namespace Eigen; using namespace Eigen;
using namespace celmath; using namespace celmath;
using celestia::util::GetLogger;
double InstantaneousCommand::getDuration() const double InstantaneousCommand::getDuration() const
@ -840,7 +842,7 @@ void CommandSetLineColor::process(ExecutionEnvironment& env)
auto &LineColorMap = env.getCelestiaCore()->scriptMaps()->LineColorMap; auto &LineColorMap = env.getCelestiaCore()->scriptMaps()->LineColorMap;
if (LineColorMap.count(item) == 0) if (LineColorMap.count(item) == 0)
{ {
cerr << "Unknown line style: " << item << "\n"; GetLogger()->warn("Unknown line style: {}\n", item);
} }
else else
{ {
@ -863,7 +865,7 @@ void CommandSetLabelColor::process(ExecutionEnvironment& env)
auto &LabelColorMap = env.getCelestiaCore()->scriptMaps()->LabelColorMap; auto &LabelColorMap = env.getCelestiaCore()->scriptMaps()->LabelColorMap;
if (LabelColorMap.count(item) == 0) if (LabelColorMap.count(item) == 0)
{ {
cerr << "Unknown label style: " << item << "\n"; GetLogger()->error("Unknown label style: {}\n", item);
} }
else else
{ {

View File

@ -22,8 +22,8 @@
#include <celscript/legacy/execution.h> #include <celscript/legacy/execution.h>
#include <celengine/timeline.h> #include <celengine/timeline.h>
#include <celengine/timelinephase.h> #include <celengine/timelinephase.h>
#include <celutil/debug.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/logger.h>
#include <celestia/celestiacore.h> #include <celestia/celestiacore.h>
#include <celestia/url.h> #include <celestia/url.h>
@ -43,6 +43,7 @@
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using celestia::util::GetLogger;
const char* CelxLua::ClassNames[] = const char* CelxLua::ClassNames[] =
{ {
@ -255,7 +256,7 @@ static void checkTimeslice(lua_State* l, lua_Debug* /*ar*/)
if (luastate->timesliceExpired()) if (luastate->timesliceExpired())
{ {
const char* errormsg = "Timeout: script hasn't returned control to celestia (forgot to call wait()?)"; const char* errormsg = "Timeout: script hasn't returned control to celestia (forgot to call wait()?)";
cerr << errormsg << "\n"; GetLogger()->error("{}\n", errormsg);
lua_pushstring(l, errormsg); lua_pushstring(l, errormsg);
lua_error(l); lua_error(l);
} }
@ -291,7 +292,10 @@ void LuaState::cleanup()
timeout = getTime() + 1.0; timeout = getTime() + 1.0;
if (lua_pcall(costate, 0, 0, 0) != 0) if (lua_pcall(costate, 0, 0, 0) != 0)
cerr << "Error while executing cleanup-callback: " << lua_tostring(costate, -1) << "\n"; {
GetLogger()->error("Error while executing cleanup-callback: {}\n",
lua_tostring(costate, -1));
}
} }
@ -429,7 +433,7 @@ bool LuaState::charEntered(const char* c_p)
CelestiaCore* appCore = getAppCore(costate, NoErrors); CelestiaCore* appCore = getAppCore(costate, NoErrors);
if (appCore == nullptr) if (appCore == nullptr)
{ {
cerr << "ERROR: appCore not found\n"; GetLogger()->error("ERROR: appCore not found\n");
return true; return true;
} }
appCore->setTextEnterMode(appCore->getTextEnterMode() & ~CelestiaCore::KbPassToScript); appCore->setTextEnterMode(appCore->getTextEnterMode() & ~CelestiaCore::KbPassToScript);
@ -448,7 +452,7 @@ bool LuaState::charEntered(const char* c_p)
} }
else else
{ {
cerr << "Oops, expected savedrenderflags to be userdata\n"; GetLogger()->warn("Oops, expected savedrenderflags to be userdata\n");
} }
lua_settop(costate,stackTop); lua_settop(costate,stackTop);
return true; return true;
@ -459,7 +463,8 @@ bool LuaState::charEntered(const char* c_p)
timeout = getTime() + 1.0; timeout = getTime() + 1.0;
if (lua_pcall(costate, 1, 1, 0) != 0) if (lua_pcall(costate, 1, 1, 0) != 0)
{ {
cerr << "Error while executing keyboard-callback: " << lua_tostring(costate, -1) << "\n"; GetLogger()->error("Error while executing keyboard-callback: {}\n",
lua_tostring(costate, -1));
result = false; result = false;
} }
else else
@ -486,7 +491,7 @@ bool LuaState::handleKeyEvent(const char* key)
lua_getfield(costate, LUA_REGISTRYINDEX, EventHandlers); lua_getfield(costate, LUA_REGISTRYINDEX, EventHandlers);
if (!lua_istable(costate, -1)) if (!lua_istable(costate, -1))
{ {
cerr << "Missing event handler table"; GetLogger()->error("Missing event handler table");
lua_pop(costate, 1); lua_pop(costate, 1);
return false; return false;
} }
@ -505,7 +510,8 @@ bool LuaState::handleKeyEvent(const char* key)
timeout = getTime() + 1.0; timeout = getTime() + 1.0;
if (lua_pcall(costate, 1, 1, 0) != 0) if (lua_pcall(costate, 1, 1, 0) != 0)
{ {
cerr << "Error while executing keyboard callback: " << lua_tostring(costate, -1) << "\n"; GetLogger()->error("Error while executing keyboard callback: {}\n",
lua_tostring(costate, -1));
} }
else else
{ {
@ -533,7 +539,7 @@ bool LuaState::handleMouseButtonEvent(float x, float y, int button, bool down)
lua_getfield(costate, LUA_REGISTRYINDEX, EventHandlers); lua_getfield(costate, LUA_REGISTRYINDEX, EventHandlers);
if (!lua_istable(costate, -1)) if (!lua_istable(costate, -1))
{ {
cerr << "Missing event handler table"; GetLogger()->error("Missing event handler table");
lua_pop(costate, 1); lua_pop(costate, 1);
return false; return false;
} }
@ -558,7 +564,8 @@ bool LuaState::handleMouseButtonEvent(float x, float y, int button, bool down)
timeout = getTime() + 1.0; timeout = getTime() + 1.0;
if (lua_pcall(costate, 1, 1, 0) != 0) if (lua_pcall(costate, 1, 1, 0) != 0)
{ {
cerr << "Error while executing keyboard callback: " << lua_tostring(costate, -1) << "\n"; GetLogger()->error("Error while executing keyboard callback: {}\n",
lua_tostring(costate, -1));
} }
else else
{ {
@ -589,7 +596,7 @@ bool LuaState::handleTickEvent(double dt)
lua_getfield(costate, LUA_REGISTRYINDEX, EventHandlers); lua_getfield(costate, LUA_REGISTRYINDEX, EventHandlers);
if (!lua_istable(costate, -1)) if (!lua_istable(costate, -1))
{ {
cerr << "Missing event handler table"; GetLogger()->error("Missing event handler table");
lua_pop(costate, 1); lua_pop(costate, 1);
return false; return false;
} }
@ -608,7 +615,8 @@ bool LuaState::handleTickEvent(double dt)
timeout = getTime() + 1.0; timeout = getTime() + 1.0;
if (lua_pcall(costate, 1, 1, 0) != 0) if (lua_pcall(costate, 1, 1, 0) != 0)
{ {
cerr << "Error while executing tick callback: " << lua_tostring(costate, -1) << "\n"; GetLogger()->error("Error while executing tick callback: {}\n",
lua_tostring(costate, -1));
} }
else else
{ {
@ -742,7 +750,7 @@ bool LuaState::tick(double dt)
CelestiaCore* appCore = getAppCore(costate, NoErrors); CelestiaCore* appCore = getAppCore(costate, NoErrors);
if (appCore == nullptr) if (appCore == nullptr)
{ {
cerr << "ERROR: appCore not found\n"; GetLogger()->error("ERROR: appCore not found\n");
return true; return true;
} }
lua_pushstring(state, "celestia-savedrenderflags"); lua_pushstring(state, "celestia-savedrenderflags");
@ -931,7 +939,7 @@ const char* Celx_SafeGetString(lua_State* l,
{ {
if (l == nullptr) if (l == nullptr)
{ {
cerr << "Error: LuaState invalid in Celx_SafeGetString\n"; GetLogger()->error("Error: LuaState invalid in Celx_SafeGetString\n");
return nullptr; return nullptr;
} }
int argc = lua_gettop(l); int argc = lua_gettop(l);
@ -958,7 +966,7 @@ lua_Number Celx_SafeGetNumber(lua_State* l, int index, FatalErrors fatalErrors,
{ {
if (l == nullptr) if (l == nullptr)
{ {
cerr << "Error: LuaState invalid in Celx_SafeGetNumber\n"; GetLogger()->error("Error: LuaState invalid in Celx_SafeGetNumber\n");
return 0.0; return 0.0;
} }
int argc = lua_gettop(l); int argc = lua_gettop(l);
@ -991,7 +999,7 @@ bool Celx_SafeGetBoolean(lua_State* l, int index, FatalErrors fatalErrors,
{ {
if (l == nullptr) if (l == nullptr)
{ {
cerr << "Error: LuaState invalid in Celx_SafeGetBoolean\n"; GetLogger()->error("Error: LuaState invalid in Celx_SafeGetBoolean\n");
return false; return false;
} }
int argc = lua_gettop(l); int argc = lua_gettop(l);
@ -1187,7 +1195,8 @@ bool LuaState::callLuaHook(void* obj, const char* method)
timeout = getTime() + 1.0; timeout = getTime() + 1.0;
if (lua_pcall(costate, 1, 1, 0) != 0) if (lua_pcall(costate, 1, 1, 0) != 0)
{ {
cerr << "Error while executing Lua Hook: " << lua_tostring(costate, -1) << "\n"; GetLogger()->error("Error while executing Lua Hook: {}\n",
lua_tostring(costate, -1));
} }
else else
{ {
@ -1230,7 +1239,8 @@ bool LuaState::callLuaHook(void* obj, const char* method, const char* keyName)
timeout = getTime() + 1.0; timeout = getTime() + 1.0;
if (lua_pcall(costate, 2, 1, 0) != 0) if (lua_pcall(costate, 2, 1, 0) != 0)
{ {
cerr << "Error while executing Lua Hook: " << lua_tostring(costate, -1) << "\n"; GetLogger()->error("Error while executing Lua Hook: {}\n",
lua_tostring(costate, -1));
} }
else else
{ {
@ -1274,7 +1284,8 @@ bool LuaState::callLuaHook(void* obj, const char* method, float x, float y)
timeout = getTime() + 1.0; timeout = getTime() + 1.0;
if (lua_pcall(costate, 3, 1, 0) != 0) if (lua_pcall(costate, 3, 1, 0) != 0)
{ {
cerr << "Error while executing Lua Hook: " << lua_tostring(costate, -1) << "\n"; GetLogger()->error("Error while executing Lua Hook: {}\n",
lua_tostring(costate, -1));
} }
else else
{ {
@ -1319,11 +1330,12 @@ bool LuaState::callLuaHook(void* obj, const char* method, float x, float y, int
timeout = getTime() + 1.0; timeout = getTime() + 1.0;
if (lua_pcall(costate, 4, 1, 0) != 0) if (lua_pcall(costate, 4, 1, 0) != 0)
{ {
cerr << "Error while executing Lua Hook: " << lua_tostring(costate, -1) << "\n"; GetLogger()->error("Error while executing Lua Hook: {}\n",
lua_tostring(costate, -1));
} }
else else
{ {
handled = lua_toboolean(costate, -1) == 1 ? true : false; handled = lua_toboolean(costate, -1) == 1;
} }
lua_pop(costate, 1); // pop the return value lua_pop(costate, 1); // pop the return value
} }
@ -1361,11 +1373,12 @@ bool LuaState::callLuaHook(void* obj, const char* method, double dt)
timeout = getTime() + 1.0; timeout = getTime() + 1.0;
if (lua_pcall(costate, 2, 1, 0) != 0) if (lua_pcall(costate, 2, 1, 0) != 0)
{ {
cerr << "Error while executing Lua Hook: " << lua_tostring(costate, -1) << "\n"; GetLogger()->error("Error while executing Lua Hook: {}\n",
lua_tostring(costate, -1));
} }
else else
{ {
handled = lua_toboolean(costate, -1) == 1 ? true : false; handled = lua_toboolean(costate, -1) == 1;
} }
lua_pop(costate, 1); // pop the return value lua_pop(costate, 1); // pop the return value
} }

View File

@ -2,7 +2,6 @@
#include <fmt/printf.h> #include <fmt/printf.h>
#include <celutil/debug.h>
#include "celx.h" #include "celx.h"
#include "celx_internal.h" #include "celx_internal.h"
#include "celx_category.h" #include "celx_category.h"

View File

@ -9,8 +9,8 @@
// as published by the Free Software Foundation; either version 2 // as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <celutil/debug.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/logger.h>
#include "celttf/truetypefont.h" #include "celttf/truetypefont.h"
#include <fmt/printf.h> #include <fmt/printf.h>
#include <celengine/category.h> #include <celengine/category.h>
@ -35,6 +35,7 @@
using namespace std; using namespace std;
using namespace Eigen; using namespace Eigen;
using namespace celestia::scripts; using namespace celestia::scripts;
using celestia::util::GetLogger;
extern const char* KbdCallback; extern const char* KbdCallback;
extern const char* CleanupCallback; extern const char* CleanupCallback;
@ -263,7 +264,7 @@ static int celestia_setrenderflags(lua_State* l)
} }
else else
{ {
cerr << "Unknown key: " << key << "\n"; GetLogger()->warn("Unknown key: {}\n", key);
} }
lua_pop(l,1); lua_pop(l,1);
} }
@ -387,7 +388,7 @@ static int celestia_setlabelflags(lua_State* l)
} }
if (LabelFlagMap.count(key) == 0) if (LabelFlagMap.count(key) == 0)
{ {
cerr << "Unknown key: " << key << "\n"; GetLogger()->warn("Unknown key: {}\n", key);
} }
else else
{ {
@ -458,7 +459,7 @@ static int celestia_setorbitflags(lua_State* l)
} }
if (BodyTypeMap.count(key) == 0) if (BodyTypeMap.count(key) == 0)
{ {
cerr << "Unknown key: " << key << "\n"; GetLogger()->warn("Unknown key: {}\n", key);
} }
else else
{ {
@ -664,7 +665,7 @@ static int celestia_setoverlayelements(lua_State* l)
} }
if (OverlayElementMap.count(key) == 0) if (OverlayElementMap.count(key) == 0)
{ {
cerr << "Unknown key: " << key << "\n"; GetLogger()->warn("Unknown key: {}\n", key);
} }
else else
{ {
@ -745,7 +746,7 @@ static int celestia_setlabelcolor(lua_State* l)
auto &LabelColorMap = this_celestia(l)->scriptMaps()->LabelColorMap; auto &LabelColorMap = this_celestia(l)->scriptMaps()->LabelColorMap;
if (LabelColorMap.count(key) == 0) if (LabelColorMap.count(key) == 0)
{ {
cerr << "Unknown label style: " << key << "\n"; GetLogger()->warn("Unknown label style: {}\n", key);
} }
else else
{ {
@ -777,7 +778,7 @@ static int celestia_getlabelcolor(lua_State* l)
auto &LabelColorMap = this_celestia(l)->scriptMaps()->LabelColorMap; auto &LabelColorMap = this_celestia(l)->scriptMaps()->LabelColorMap;
if (LabelColorMap.count(key) == 0) if (LabelColorMap.count(key) == 0)
{ {
cerr << "Unknown label style: " << key << "\n"; GetLogger()->error("Unknown label style: {}\n", key);
return 0; return 0;
} }
@ -805,7 +806,7 @@ static int celestia_setlinecolor(lua_State* l)
auto &LineColorMap = this_celestia(l)->scriptMaps()->LineColorMap; auto &LineColorMap = this_celestia(l)->scriptMaps()->LineColorMap;
if (LineColorMap.count(key) == 0) if (LineColorMap.count(key) == 0)
{ {
cerr << "Unknown line style: " << key << "\n"; GetLogger()->warn("Unknown line style: {}\n", key);
} }
else else
{ {
@ -836,7 +837,7 @@ static int celestia_getlinecolor(lua_State* l)
auto &LineColorMap = this_celestia(l)->scriptMaps()->LineColorMap; auto &LineColorMap = this_celestia(l)->scriptMaps()->LineColorMap;
if (LineColorMap.count(key) == 0) if (LineColorMap.count(key) == 0)
{ {
cerr << "Unknown line style: " << key << "\n"; GetLogger()->error("Unknown line style: {}\n", key);
return 0; return 0;
} }

View File

@ -7,7 +7,6 @@
// as published by the Free Software Foundation; either version 2 // as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version. // of the License, or (at your option) any later version.
#include <celutil/debug.h>
#include "celx_misc.h" #include "celx_misc.h"
#include "celx_internal.h" #include "celx_internal.h"
#include <celscript/legacy/cmdparser.h> #include <celscript/legacy/cmdparser.h>

View File

@ -22,9 +22,11 @@
#include <celengine/multitexture.h> #include <celengine/multitexture.h>
#include <celestia/celestiacore.h> #include <celestia/celestiacore.h>
#include <celscript/common/scriptmaps.h> #include <celscript/common/scriptmaps.h>
#include <celutil/logger.h>
using namespace Eigen; using namespace Eigen;
using namespace std; using namespace std;
using celestia::util::GetLogger;
static const char* bodyTypeName(int cl) static const char* bodyTypeName(int cl)
@ -264,7 +266,7 @@ static int object_setorbitvisibility(lua_State* l)
auto &OrbitVisibilityMap = celx.appCore(AllErrors)->scriptMaps()->OrbitVisibilityMap; auto &OrbitVisibilityMap = celx.appCore(AllErrors)->scriptMaps()->OrbitVisibilityMap;
if (OrbitVisibilityMap.count(key) == 0) if (OrbitVisibilityMap.count(key) == 0)
{ {
cerr << "Unknown visibility policy: " << key << endl; GetLogger()->warn("Unknown visibility policy: {}\n", key);
} }
else else
{ {

View File

@ -16,11 +16,13 @@
//#include <celengine/body.h> //#include <celengine/body.h>
//#include <celengine/timelinephase.h> //#include <celengine/timelinephase.h>
#include <celestia/celestiacore.h> #include <celestia/celestiacore.h>
#include <celutil/logger.h>
#include <Eigen/Geometry> #include <Eigen/Geometry>
using namespace std; using namespace std;
using namespace Eigen; using namespace Eigen;
using namespace celmath; using namespace celmath;
using celestia::util::GetLogger;
// ==================== Observer ==================== // ==================== Observer ====================
@ -898,7 +900,7 @@ static int observer_setlocationflags(lua_State* l)
auto &LocationFlagMap = celx.appCore(AllErrors)->scriptMaps()->LocationFlagMap; auto &LocationFlagMap = celx.appCore(AllErrors)->scriptMaps()->LocationFlagMap;
if (LocationFlagMap.count(key) == 0) if (LocationFlagMap.count(key) == 0)
{ {
cerr << "Unknown key: " << key << "\n"; GetLogger()->warn("Unknown key: {}\n", key);
} }
else else
{ {

View File

@ -16,6 +16,7 @@
#include <celestia/configfile.h> #include <celestia/configfile.h>
#include <celestia/celestiacore.h> #include <celestia/celestiacore.h>
#include <celutil/gettext.h> #include <celutil/gettext.h>
#include <celutil/logger.h>
#include "celx_internal.h" #include "celx_internal.h"
#include "luascript.h" #include "luascript.h"
@ -23,6 +24,8 @@ using namespace std;
namespace celestia namespace celestia
{ {
using util::GetLogger;
namespace scripts namespace scripts
{ {
@ -167,7 +170,7 @@ static string lua_path(const CelestiaConfig *config)
std::error_code ec; std::error_code ec;
if (!fs::is_directory(dir, ec)) if (!fs::is_directory(dir, ec))
{ {
cerr << fmt::sprintf(_("Path %s doesn't exist or isn't a directory\n"), dir); GetLogger()->warn(_("Path {} doesn't exist or isn't a directory\n"), dir);
continue; continue;
} }
@ -222,7 +225,7 @@ bool CreateLuaEnvironment(CelestiaCore *appCore, const CelestiaConfig *config, P
if (status != 0) if (status != 0)
{ {
cerr << "lua hook load failed\n"; GetLogger()->debug("lua hook load failed\n");
string errMsg = luaHook->getErrorMessage(); string errMsg = luaHook->getErrorMessage();
if (errMsg.empty()) if (errMsg.empty())
errMsg = _("Unknown error loading hook script"); errMsg = _("Unknown error loading hook script");
@ -235,7 +238,7 @@ bool CreateLuaEnvironment(CelestiaCore *appCore, const CelestiaConfig *config, P
// script and Celestia's event loop // script and Celestia's event loop
if (!luaHook->createThread()) if (!luaHook->createThread())
{ {
cerr << "hook thread failed\n"; GetLogger()->debug("hook thread failed\n");
appCore->fatalError(_("Script coroutine initialization failed")); appCore->fatalError(_("Script coroutine initialization failed"));
luaHook = nullptr; luaHook = nullptr;
} }

Some files were not shown because too many files have changed in this diff Show More