From 9c371c891c8b775e755ab54caa252eacedc9de52 Mon Sep 17 00:00:00 2001 From: Li Linfeng Date: Thu, 29 Aug 2019 10:29:36 +0800 Subject: [PATCH] define macros for print levels and avoid direct use of fmt::printf --- src/cel3ds/3dsread.cpp | 8 ++++---- src/celengine/asterism.cpp | 6 +++--- src/celengine/category.cpp | 12 ++++++------ src/celengine/dds.cpp | 8 ++++---- src/celengine/dsodb.cpp | 20 ++++++++++---------- src/celengine/galaxy.cpp | 2 +- src/celengine/globular.cpp | 2 +- src/celengine/image.cpp | 4 ++-- src/celengine/meshmanager.cpp | 12 ++++++------ src/celengine/name.cpp | 2 +- src/celengine/overlay.cpp | 2 +- src/celengine/parseobject.cpp | 14 +++++++------- src/celengine/planetgrid.cpp | 2 +- src/celengine/rotationmanager.cpp | 2 +- src/celengine/selection.cpp | 2 +- src/celengine/shadermanager.cpp | 2 +- src/celengine/solarsys.cpp | 2 +- src/celengine/star.cpp | 2 +- src/celengine/stardb.cpp | 18 +++++++++--------- src/celengine/stellarclass.cpp | 2 +- src/celengine/texmanager.cpp | 4 ++-- src/celengine/texture.cpp | 2 +- src/celengine/trajmanager.cpp | 4 ++-- src/celengine/virtualtex.cpp | 14 +++++++------- src/celephem/customorbit.cpp | 2 +- src/celephem/orbit.cpp | 2 +- src/celephem/samporbit.cpp | 2 +- src/celephem/scriptobject.cpp | 2 +- src/celestia/celestiacore.cpp | 9 ++++----- src/celestia/celx.cpp | 2 +- src/celestia/celx_category.cpp | 2 +- src/celestia/celx_celestia.cpp | 2 +- src/celestia/celx_misc.cpp | 2 +- src/celestia/cmdparser.cpp | 4 ++-- src/celestia/configfile.cpp | 30 +++++++++++++++--------------- src/celestia/destination.cpp | 6 +++--- src/celestia/favorites.cpp | 4 ++-- src/celestia/imagecapture.cpp | 10 +++++----- src/celestia/oggtheoracapture.cpp | 23 ++++++++++++----------- src/celestia/url.cpp | 2 +- src/celmodel/modelfile.cpp | 2 +- src/celtxf/texturefont.cpp | 26 +++++++++++++------------- src/celutil/bigfix.cpp | 21 +++++++++++---------- src/celutil/debug.h | 7 +++++++ src/celutil/util.cpp | 2 +- 45 files changed, 159 insertions(+), 151 deletions(-) diff --git a/src/cel3ds/3dsread.cpp b/src/cel3ds/3dsread.cpp index 95bc264b..e8562266 100644 --- a/src/cel3ds/3dsread.cpp +++ b/src/cel3ds/3dsread.cpp @@ -620,18 +620,18 @@ M3DScene* Read3DSFile(ifstream& in) unsigned short chunkType = readUshort(in); if (chunkType != M3DCHUNK_MAGIC) { - DPRINTF(0, "Read3DSFile: Wrong magic number in header\n"); + DPRINTF(LOG_LEVEL_ERROR, "Read3DSFile: Wrong magic number in header\n"); return nullptr; } int32_t chunkSize = readInt(in); if (in.bad()) { - DPRINTF(0, "Read3DSFile: Error reading 3DS file.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Read3DSFile: Error reading 3DS file.\n"); return nullptr; } - DPRINTF(1, "3DS file, %d bytes\n", chunkSize); + DPRINTF(LOG_LEVEL_INFO, "3DS file, %d bytes\n", chunkSize); auto* scene = new M3DScene(); int contentSize = chunkSize - 6; @@ -647,7 +647,7 @@ M3DScene* Read3DSFile(const fs::path& filename) ifstream in(filename.string(), ios::in | ios::binary); if (!in.good()) { - DPRINTF(0, "Read3DSFile: Error opening %s\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "Read3DSFile: Error opening %s\n", filename); return nullptr; } diff --git a/src/celengine/asterism.cpp b/src/celengine/asterism.cpp index 5587a33f..5c89498d 100644 --- a/src/celengine/asterism.cpp +++ b/src/celengine/asterism.cpp @@ -217,7 +217,7 @@ AsterismList* ReadAsterismList(istream& in, const StarDatabase& stardb) { if (tokenizer.getTokenType() != Tokenizer::TokenString) { - DPRINTF(0, "Error parsing asterism file.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Error parsing asterism file.\n"); for_each(asterisms->begin(), asterisms->end(), deleteFunc()); delete asterisms; return nullptr; @@ -229,7 +229,7 @@ AsterismList* ReadAsterismList(istream& in, const StarDatabase& stardb) Value* chainsValue = parser.readValue(); if (chainsValue == nullptr || chainsValue->getType() != Value::ArrayType) { - DPRINTF(0, "Error parsing asterism %s\n", name.c_str()); + DPRINTF(LOG_LEVEL_ERROR, "Error parsing asterism %s\n", name.c_str()); for_each(asterisms->begin(), asterisms->end(), deleteFunc()); delete ast; delete asterisms; @@ -258,7 +258,7 @@ AsterismList* ReadAsterismList(istream& in, const StarDatabase& stardb) star = stardb.find(ReplaceGreekLetterAbbr(i->getString())); if (star != nullptr) new_chain->push_back(star->getPosition()); - else DPRINTF(0, "Error loading star \"%s\" for asterism \"%s\".\n", name.c_str(), i->getString().c_str()); + else DPRINTF(LOG_LEVEL_ERROR, "Error loading star \"%s\" for asterism \"%s\".\n", name.c_str(), i->getString().c_str()); } } diff --git a/src/celengine/category.cpp b/src/celengine/category.cpp index 70047814..ae1d49d3 100644 --- a/src/celengine/category.cpp +++ b/src/celengine/category.cpp @@ -93,19 +93,19 @@ bool UserCategory::hasChild(const std::string &n) const void UserCategory::cleanup() { - DPRINTF(1, "UserCategory::cleanup()\n"); - DPRINTF(1, " Objects: %i\n", m_objlist.size()); - DPRINTF(1, " Categories: %i\n", m_catlist.size()); + DPRINTF(LOG_LEVEL_INFO, "UserCategory::cleanup()\n"); + DPRINTF(LOG_LEVEL_INFO, " Objects: %i\n", m_objlist.size()); + DPRINTF(LOG_LEVEL_INFO, " Categories: %i\n", m_catlist.size()); while(!m_objlist.empty()) { auto it = m_objlist.begin(); - DPRINTF(1, "Removing object: %s\n", it->getName()); + DPRINTF(LOG_LEVEL_INFO, "Removing object: %s\n", it->getName()); removeObject(*it); } while(!m_catlist.empty()) { auto it = m_catlist.begin(); - DPRINTF(1, "Removing category: %s\n", (*it)->name()); + DPRINTF(LOG_LEVEL_INFO, "Removing category: %s\n", (*it)->name()); deleteChild(*it); } } @@ -135,7 +135,7 @@ UserCategory *UserCategory::find(const std::string &s) { if (m_allcats.count(s) == 0) return nullptr; - DPRINTF(1, "UserCategory::find(%s): exists\n", s.c_str()); + DPRINTF(LOG_LEVEL_INFO, "UserCategory::find(%s): exists\n", s.c_str()); return m_allcats.find(s)->second; } diff --git a/src/celengine/dds.cpp b/src/celengine/dds.cpp index 12aefa79..88ebeed3 100644 --- a/src/celengine/dds.cpp +++ b/src/celengine/dds.cpp @@ -88,7 +88,7 @@ Image* LoadDDSImage(const fs::path& filename) ifstream in(filename.string(), ios::in | ios::binary); if (!in.good()) { - DPRINTF(0, "Error opening DDS texture file %s.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "Error opening DDS texture file %s.\n", filename); return nullptr; } @@ -97,7 +97,7 @@ Image* LoadDDSImage(const fs::path& filename) if (header[0] != 'D' || header[1] != 'D' || header[2] != 'S' || header[3] != ' ') { - DPRINTF(0, "DDS texture file %s has bad header.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "DDS texture file %s has bad header.\n", filename); return nullptr; } @@ -176,7 +176,7 @@ Image* LoadDDSImage(const fs::path& filename) if (format == -1) { - DPRINTF(0, "Unsupported format for DDS texture file %s.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "Unsupported format for DDS texture file %s.\n", filename); return nullptr; } @@ -200,7 +200,7 @@ Image* LoadDDSImage(const fs::path& filename) in.read(reinterpret_cast(img->getPixels()), img->getSize()); if (!in.eof() && !in.good()) { - DPRINTF(0, "Failed reading data from DDS texture file %s.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "Failed reading data from DDS texture file %s.\n", filename); delete img; return nullptr; } diff --git a/src/celengine/dsodb.cpp b/src/celengine/dsodb.cpp index 54fa6518..b0f68e77 100644 --- a/src/celengine/dsodb.cpp +++ b/src/celengine/dsodb.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -231,7 +231,7 @@ bool DSODatabase::load(istream& in, const fs::path& resourcePath) if (tokenizer.getTokenType() != Tokenizer::TokenName) { - DPRINTF(0, "Error parsing deep sky catalog file.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Error parsing deep sky catalog file.\n"); return false; } objType = tokenizer.getNameValue(); @@ -252,7 +252,7 @@ bool DSODatabase::load(istream& in, const fs::path& resourcePath) if (tokenizer.nextToken() != Tokenizer::TokenString) { - DPRINTF(0, "Error parsing deep sky catalog file: bad name.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Error parsing deep sky catalog file: bad name.\n"); return false; } objName = tokenizer.getStringValue(); @@ -261,7 +261,7 @@ bool DSODatabase::load(istream& in, const fs::path& resourcePath) if (objParamsValue == nullptr || objParamsValue->getType() != Value::HashType) { - DPRINTF(0, "Error parsing deep sky catalog entry %s\n", objName.c_str()); + DPRINTF(LOG_LEVEL_ERROR, "Error parsing deep sky catalog entry %s\n", objName.c_str()); return false; } @@ -339,7 +339,7 @@ bool DSODatabase::load(istream& in, const fs::path& resourcePath) } else { - DPRINTF(1, "Bad Deep Sky Object definition--will continue parsing file.\n"); + DPRINTF(LOG_LEVEL_WARNING, "Bad Deep Sky Object definition--will continue parsing file.\n"); delete objParamsValue; return false; } @@ -374,7 +374,7 @@ void DSODatabase::finish() void DSODatabase::buildOctree() { - DPRINTF(1, "Sorting DSOs into octree . . .\n"); + DPRINTF(LOG_LEVEL_INFO, "Sorting DSOs into octree . . .\n"); 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 @@ -386,7 +386,7 @@ void DSODatabase::buildOctree() root->insertObject(DSOs[i], DSO_OCTREE_ROOT_SIZE); } - DPRINTF(1, "Spatially sorting DSOs for improved locality of reference . . .\n"); + DPRINTF(LOG_LEVEL_INFO, "Spatially sorting DSOs for improved locality of reference . . .\n"); DeepSkyObject** sortedDSOs = new DeepSkyObject*[nDSOs]; DeepSkyObject** firstDSO = sortedDSOs; @@ -394,8 +394,8 @@ void DSODatabase::buildOctree() // are storing pointers to objects and not the objects themselves: root->rebuildAndSort(octreeRoot, firstDSO); - DPRINTF(1, "%d DSOs total\n", (int) (firstDSO - sortedDSOs)); - DPRINTF(1, "Octree has %d nodes and %d DSOs.\n", + DPRINTF(LOG_LEVEL_INFO, "%d DSOs total\n", (int) (firstDSO - sortedDSOs)); + DPRINTF(LOG_LEVEL_INFO, "Octree has %d nodes and %d DSOs.\n", 1 + octreeRoot->countChildren(), octreeRoot->countObjects()); //cout<<"DSOs: "<< octreeRoot->countObjects()<<" Nodes:" // <countChildren() < #include #include -#include +#include #include using namespace Eigen; diff --git a/src/celengine/globular.cpp b/src/celengine/globular.cpp index 1d46e388..c3b4d1f3 100644 --- a/src/celengine/globular.cpp +++ b/src/celengine/globular.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include using namespace Eigen; using namespace std; diff --git a/src/celengine/image.cpp b/src/celengine/image.cpp index a69cdd9e..45eda934 100644 --- a/src/celengine/image.cpp +++ b/src/celengine/image.cpp @@ -25,7 +25,7 @@ extern "C" { #include #include #include -#include +#include #include "image.h" @@ -331,7 +331,7 @@ Image* LoadImageFromFile(const fs::path& filename) img = LoadDDSImage(filename); break; default: - fmt::printf(_("%s: unrecognized or unsupported image file type.\n"), filename.string()); + DPRINTF(LOG_LEVEL_ERROR, "%s: unrecognized or unsupported image file type.\n", filename.string()); break; } diff --git a/src/celengine/meshmanager.cpp b/src/celengine/meshmanager.cpp index 584256b2..7e9158d4 100644 --- a/src/celengine/meshmanager.cpp +++ b/src/celengine/meshmanager.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include @@ -246,7 +246,7 @@ Model* LoadCelestiaMesh(const fs::path& filename) ifstream meshFile(filename.string(), ios::in); if (!meshFile.good()) { - DPRINTF(0, "Error opening mesh file: %s\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "Error opening mesh file: %s\n", filename); return nullptr; } @@ -255,13 +255,13 @@ Model* LoadCelestiaMesh(const fs::path& filename) if (tokenizer.nextToken() != Tokenizer::TokenName) { - DPRINTF(0, "Mesh file %s is invalid.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "Mesh file %s is invalid.\n", filename); return nullptr; } if (tokenizer.getStringValue() != "SphereDisplacementMesh") { - DPRINTF(0, "%s: Unrecognized mesh type %s.\n", + DPRINTF(LOG_LEVEL_ERROR, "%s: Unrecognized mesh type %s.\n", filename, tokenizer.getStringValue()); return nullptr; } @@ -269,13 +269,13 @@ Model* LoadCelestiaMesh(const fs::path& filename) Value* meshDefValue = parser.readValue(); if (meshDefValue == nullptr) { - DPRINTF(0, "%s: Bad mesh file.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: Bad mesh file.\n", filename); return nullptr; } if (meshDefValue->getType() != Value::HashType) { - DPRINTF(0, "%s: Bad mesh file.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: Bad mesh file.\n", filename); delete meshDefValue; return nullptr; } diff --git a/src/celengine/name.cpp b/src/celengine/name.cpp index 8bfb30b8..34e17aa6 100644 --- a/src/celengine/name.cpp +++ b/src/celengine/name.cpp @@ -13,7 +13,7 @@ void NameDatabase::add(const uint32_t catalogNumber, const std::string& name, bo #ifdef DEBUG uint32_t tmp; if ((tmp = getCatalogNumberByName(name)) != InvalidCatalogNumber) - DPRINTF(2,"Duplicated name '%s' on object with catalog numbers: %d and %d\n", name.c_str(), tmp, catalogNumber); + DPRINTF(LOG_LEVEL_INFO,"Duplicated name '%s' on object with catalog numbers: %d and %d\n", name.c_str(), tmp, catalogNumber); #endif // Add the new name //nameIndex.insert(NameIndex::value_type(name, catalogNumber)); diff --git a/src/celengine/overlay.cpp b/src/celengine/overlay.cpp index bee220db..620f6d2d 100644 --- a/src/celengine/overlay.cpp +++ b/src/celengine/overlay.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include "vecgl.h" #include "overlay.h" #include "render.h" diff --git a/src/celengine/parseobject.cpp b/src/celengine/parseobject.cpp index 1e66e644..2ce33504 100644 --- a/src/celengine/parseobject.cpp +++ b/src/celengine/parseobject.cpp @@ -254,7 +254,7 @@ CreateSampledTrajectory(Hash* trajData, const fs::path& path) trajData->getBoolean("DoublePrecision", useDoublePrecision); TrajectoryPrecision precision = useDoublePrecision ? TrajectoryPrecisionDouble : TrajectoryPrecisionSingle; - DPRINTF(1, "Attempting to load sampled trajectory from source '%s'\n", sourceName.c_str()); + DPRINTF(LOG_LEVEL_INFO, "Attempting to load sampled trajectory from source '%s'\n", sourceName.c_str()); ResourceHandle orbitHandle = GetTrajectoryManager()->getHandle(TrajectoryInfo(sourceName, path, interpolation, precision)); Orbit* orbit = GetTrajectoryManager()->find(orbitHandle); if (orbit == nullptr) @@ -704,7 +704,7 @@ CreateOrbit(const Selection& centralObject, return orbit; } clog << "Bad spice orbit\n"; - DPRINTF(0, "Could not load SPICE orbit\n"); + DPRINTF(LOG_LEVEL_ERROR, "Could not load SPICE orbit\n"); } } #endif @@ -743,7 +743,7 @@ CreateOrbit(const Selection& centralObject, string sampOrbitFile; if (planetData->getString("SampledOrbit", sampOrbitFile)) { - DPRINTF(1, "Attempting to load sampled orbit file '%s'\n", + DPRINTF(LOG_LEVEL_INFO, "Attempting to load sampled orbit file '%s'\n", sampOrbitFile.c_str()); ResourceHandle orbitHandle = GetTrajectoryManager()->getHandle(TrajectoryInfo(sampOrbitFile, @@ -1089,7 +1089,7 @@ CreateRotationModel(Hash* planetData, return rotationModel; } clog << "Bad spice rotation model\n"; - DPRINTF(0, "Could not load SPICE rotation model\n"); + DPRINTF(LOG_LEVEL_ERROR, "Could not load SPICE rotation model\n"); } } #endif @@ -1112,7 +1112,7 @@ CreateRotationModel(Hash* planetData, string sampOrientationFile; if (planetData->getString("SampledOrientation", sampOrientationFile)) { - DPRINTF(1, "Attempting to load orientation file '%s'\n", + DPRINTF(LOG_LEVEL_INFO, "Attempting to load orientation file '%s'\n", sampOrientationFile.c_str()); ResourceHandle orientationHandle = GetRotationModelManager()->getHandle(RotationModelInfo(sampOrientationFile, path)); @@ -1406,14 +1406,14 @@ getAxis(Hash* vectorData) string axisLabel; if (!vectorData->getString("Axis", axisLabel)) { - DPRINTF(0, "Bad two-vector frame: missing axis label for vector.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Bad two-vector frame: missing axis label for vector.\n"); return 0; } int axis = parseAxisLabel(axisLabel); if (axis == 0) { - DPRINTF(0, "Bad two-vector frame: vector has invalid axis label.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Bad two-vector frame: vector has invalid axis label.\n"); } // Permute axis labels to match non-standard Celestia coordinate diff --git a/src/celengine/planetgrid.cpp b/src/celengine/planetgrid.cpp index 515975b5..4e7b4100 100644 --- a/src/celengine/planetgrid.cpp +++ b/src/celengine/planetgrid.cpp @@ -18,7 +18,7 @@ #include #include #include -#include +#include using namespace Eigen; using namespace celmath; diff --git a/src/celengine/rotationmanager.cpp b/src/celengine/rotationmanager.cpp index b9a3f361..492d5ee3 100644 --- a/src/celengine/rotationmanager.cpp +++ b/src/celengine/rotationmanager.cpp @@ -44,7 +44,7 @@ fs::path RotationModelInfo::resolve(const fs::path& baseDir) RotationModel* RotationModelInfo::load(const fs::path& filename) { - DPRINTF(1, "Loading rotation model: %s\n", filename); + DPRINTF(LOG_LEVEL_INFO, "Loading rotation model: %s\n", filename); return LoadSampledOrientation(filename); } diff --git a/src/celengine/selection.cpp b/src/celengine/selection.cpp index 0138b03c..38b6298e 100644 --- a/src/celengine/selection.cpp +++ b/src/celengine/selection.cpp @@ -8,7 +8,7 @@ // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. -#include +#include #include #include "astro.h" #include "selection.h" diff --git a/src/celengine/shadermanager.cpp b/src/celengine/shadermanager.cpp index b8f37423..975da57f 100644 --- a/src/celengine/shadermanager.cpp +++ b/src/celengine/shadermanager.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/celengine/solarsys.cpp b/src/celengine/solarsys.cpp index 83c34c87..bd7a1e51 100644 --- a/src/celengine/solarsys.cpp +++ b/src/celengine/solarsys.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include "astro.h" #include "parser.h" #include "texmanager.h" diff --git a/src/celengine/star.cpp b/src/celengine/star.cpp index 5b4c623f..ec487867 100644 --- a/src/celengine/star.cpp +++ b/src/celengine/star.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include "astro.h" #include "star.h" diff --git a/src/celengine/stardb.cpp b/src/celengine/stardb.cpp index a2d18884..48b6410d 100644 --- a/src/celengine/stardb.cpp +++ b/src/celengine/stardb.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -690,7 +690,7 @@ bool StarDatabase::loadBinary(istream& in) if (in.bad()) return false; - DPRINTF(0, "StarDatabase::read: nStars = %d\n", nStarsInFile); + DPRINTF(LOG_LEVEL_ERROR, "StarDatabase::read: nStars = %d\n", nStarsInFile); fmt::fprintf(clog, _("%d stars in binary database\n"), nStars); // Create the temporary list of stars sorted by catalog number; this @@ -1294,7 +1294,7 @@ bool StarDatabase::load(istream& in, const fs::path& resourcePath) if (starDataValue->getType() != Value::HashType) { - DPRINTF(0, "Bad star definition.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Bad star definition.\n"); delete starDataValue; return false; } @@ -1358,7 +1358,7 @@ bool StarDatabase::load(istream& in, const fs::path& resourcePath) { if (isNewStar) delete star; - DPRINTF(1, "Bad star definition--will continue parsing file.\n"); + DPRINTF(LOG_LEVEL_INFO, "Bad star definition--will continue parsing file.\n"); } } @@ -1371,7 +1371,7 @@ void StarDatabase::buildOctree() // This should only be called once for the database // ASSERT(octreeRoot == nullptr); - DPRINTF(1, "Sorting stars into octree . . .\n"); + DPRINTF(LOG_LEVEL_INFO, "Sorting stars into octree . . .\n"); float absMag = astro::appToAbsMag(STAR_OCTREE_MAGNITUDE, STAR_OCTREE_ROOT_SIZE * (float) sqrt(3.0)); DynamicStarOctree* root = new DynamicStarOctree(Vector3f(1000.0f, 1000.0f, 1000.0f), @@ -1381,14 +1381,14 @@ void StarDatabase::buildOctree() root->insertObject(unsortedStars[i], STAR_OCTREE_ROOT_SIZE); } - DPRINTF(1, "Spatially sorting stars for improved locality of reference . . .\n"); + DPRINTF(LOG_LEVEL_INFO, "Spatially sorting stars for improved locality of reference . . .\n"); Star* sortedStars = new Star[nStars]; Star* firstStar = sortedStars; root->rebuildAndSort(octreeRoot, firstStar); // ASSERT((int) (firstStar - sortedStars) == nStars); - DPRINTF(1, "%d stars total\n", (int) (firstStar - sortedStars)); - DPRINTF(1, "Octree has %d nodes and %d stars.\n", + DPRINTF(LOG_LEVEL_INFO, "%d stars total\n", (int) (firstStar - sortedStars)); + DPRINTF(LOG_LEVEL_INFO, "Octree has %d nodes and %d stars.\n", 1 + octreeRoot->countChildren(), octreeRoot->countObjects()); #ifdef PROFILE_OCTREE vector stats; @@ -1420,7 +1420,7 @@ void StarDatabase::buildIndexes() // This should only be called once for the database // assert(catalogNumberIndexes[0] == nullptr); - DPRINTF(1, "Building catalog number indexes . . .\n"); + DPRINTF(LOG_LEVEL_INFO, "Building catalog number indexes . . .\n"); catalogNumberIndex = new Star*[nStars]; for (int i = 0; i < nStars; ++i) diff --git a/src/celengine/stellarclass.cpp b/src/celengine/stellarclass.cpp index 096dfc46..1be98bd1 100644 --- a/src/celengine/stellarclass.cpp +++ b/src/celengine/stellarclass.cpp @@ -8,7 +8,7 @@ // of the License, or (at your option) any later version. #include -#include +#include #include #include #include "stellarclass.h" diff --git a/src/celengine/texmanager.cpp b/src/celengine/texmanager.cpp index cf7327e5..f06fdd21 100644 --- a/src/celengine/texmanager.cpp +++ b/src/celengine/texmanager.cpp @@ -129,13 +129,13 @@ Texture* TextureInfo::load(const fs::path& name) if (bumpHeight == 0.0f) { - DPRINTF(0, "Loading texture: %s\n", name.c_str()); + DPRINTF(LOG_LEVEL_ERROR, "Loading texture: %s\n", name.c_str()); // cout << "Loading texture: " << name << '\n'; return LoadTextureFromFile(name, addressMode, mipMode); } - DPRINTF(0, "Loading bump map: %s\n", name.c_str()); + DPRINTF(LOG_LEVEL_ERROR, "Loading bump map: %s\n", name.c_str()); // cout << "Loading texture: " << name << '\n'; return LoadHeightMapFromFile(name, bumpHeight, addressMode); diff --git a/src/celengine/texture.cpp b/src/celengine/texture.cpp index 0c05b95c..d9247279 100644 --- a/src/celengine/texture.cpp +++ b/src/celengine/texture.cpp @@ -25,7 +25,7 @@ extern "C" { #include #include #include -#include +#include #include "texture.h" #include "virtualtex.h" diff --git a/src/celengine/trajmanager.cpp b/src/celengine/trajmanager.cpp index b50eab39..1ab4c3b0 100644 --- a/src/celengine/trajmanager.cpp +++ b/src/celengine/trajmanager.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include using namespace std; @@ -64,7 +64,7 @@ Orbit* TrajectoryInfo::load(const fs::path& filename) fs::path strippedFilename = filename.string().substr(0, uniquifyingSuffixStart); ContentType filetype = DetermineFileType(strippedFilename); - DPRINTF(1, "Loading trajectory: %s\n", strippedFilename); + DPRINTF(LOG_LEVEL_INFO, "Loading trajectory: %s\n", strippedFilename); Orbit* sampTrajectory = nullptr; diff --git a/src/celengine/virtualtex.cpp b/src/celengine/virtualtex.cpp index 708a1349..c3297e33 100644 --- a/src/celengine/virtualtex.cpp +++ b/src/celengine/virtualtex.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -313,7 +313,7 @@ static VirtualTexture* CreateVirtualTexture(Hash* texParams, string imageDirectory; if (!texParams->getString("ImageDirectory", imageDirectory)) { - DPRINTF(0, "ImageDirectory missing in virtual texture.\n"); + DPRINTF(LOG_LEVEL_ERROR, "ImageDirectory missing in virtual texture.\n"); return nullptr; } @@ -321,14 +321,14 @@ static VirtualTexture* CreateVirtualTexture(Hash* texParams, if (!texParams->getNumber("BaseSplit", baseSplit) || baseSplit < 0.0 || baseSplit != floor(baseSplit)) { - DPRINTF(0, "BaseSplit in virtual texture missing or has bad value\n"); + DPRINTF(LOG_LEVEL_ERROR, "BaseSplit in virtual texture missing or has bad value\n"); return nullptr; } double tileSize = 0.0; if (!texParams->getNumber("TileSize", tileSize)) { - DPRINTF(0, "TileSize is missing from virtual texture\n"); + DPRINTF(LOG_LEVEL_ERROR, "TileSize is missing from virtual texture\n"); return nullptr; } @@ -336,7 +336,7 @@ static VirtualTexture* CreateVirtualTexture(Hash* texParams, tileSize < 64.0 || !isPow2((int) tileSize)) { - DPRINTF(0, "Virtual texture tile size must be a power of two >= 64\n"); + DPRINTF(LOG_LEVEL_ERROR, "Virtual texture tile size must be a power of two >= 64\n"); return nullptr; } @@ -375,7 +375,7 @@ static VirtualTexture* LoadVirtualTexture(istream& in, const fs::path& path) Value* texParamsValue = parser.readValue(); if (texParamsValue == nullptr || texParamsValue->getType() != Value::HashType) { - DPRINTF(0, "Error parsing virtual texture\n"); + DPRINTF(LOG_LEVEL_ERROR, "Error parsing virtual texture\n"); delete texParamsValue; return nullptr; } @@ -395,7 +395,7 @@ VirtualTexture* LoadVirtualTexture(const fs::path& filename) if (!in.good()) { - //DPRINTF(0, "Error opening virtual texture file: %s\n", filename.c_str()); + //DPRINTF(LOG_LEVEL_ERROR, "Error opening virtual texture file: %s\n", filename.c_str()); return nullptr; } diff --git a/src/celephem/customorbit.cpp b/src/celephem/customorbit.cpp index f67c004e..af10d422 100644 --- a/src/celephem/customorbit.cpp +++ b/src/celephem/customorbit.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include using namespace Eigen; using namespace std; diff --git a/src/celephem/orbit.cpp b/src/celephem/orbit.cpp index fc1e169f..14248468 100644 --- a/src/celephem/orbit.cpp +++ b/src/celephem/orbit.cpp @@ -297,7 +297,7 @@ double EllipticalOrbit::eccentricAnomaly(double M) const // much faster converging iteration. Solution sol = solve_iteration_fixed(SolveKeplerFunc2(eccentricity, M), M, 6); // Debugging - // fmt::printf("ecc: %f, error: %f mas\n", + // DPRINTF(LOG_LEVEL_INFO, "ecc: %f, error: %f mas\n", // eccentricity, radToDeg(sol.second) * 3600000); return sol.first; } diff --git a/src/celephem/samporbit.cpp b/src/celephem/samporbit.cpp index 58ea52df..b972dd34 100644 --- a/src/celephem/samporbit.cpp +++ b/src/celephem/samporbit.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include using namespace Eigen; using namespace std; diff --git a/src/celephem/scriptobject.cpp b/src/celephem/scriptobject.cpp index 4e8fb874..ffe5e971 100644 --- a/src/celephem/scriptobject.cpp +++ b/src/celephem/scriptobject.cpp @@ -9,7 +9,7 @@ // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. -#include +#include #include "scriptobject.h" diff --git a/src/celestia/celestiacore.cpp b/src/celestia/celestiacore.cpp index 43fd1c04..fab7a63b 100644 --- a/src/celestia/celestiacore.cpp +++ b/src/celestia/celestiacore.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include @@ -438,8 +438,7 @@ void showSelectionInfo(const Selection& sel) AngleAxisf aa(orientation); - fmt::printf(_("%s\nOrientation: [%f, %f, %f], %.1f\n"), - sel.getName(), aa.axis().x(), aa.axis().y(), aa.axis().z(), radToDeg(aa.angle())); + 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())); } @@ -4006,7 +4005,7 @@ template class CatalogLoader if (catalogFile.good()) { if (!objDB->load(catalogFile, filepath.parent_path())) - DPRINTF(0, "Error reading %s catalog file: %s\n", typeDesc.c_str(), filepath.string()); + DPRINTF(LOG_LEVEL_ERROR, "Error reading %s catalog file: %s\n", typeDesc.c_str(), filepath.string()); } } }; @@ -4253,7 +4252,7 @@ bool CelestiaCore::initRenderer() context->init(config->ignoreGLExtensions); // Choose the render path, starting with the least desirable context->setRenderPath(GLContext::GLPath_GLSL); - //fmt::printf(_("render path: %i\n"), context->getRenderPath()); + //DPRINTF(LOG_LEVEL_VERBOSE, "render path: %i\n", context->getRenderPath()); #endif Renderer::DetailOptions detailOptions; diff --git a/src/celestia/celx.cpp b/src/celestia/celx.cpp index 728c641f..e597d272 100644 --- a/src/celestia/celx.cpp +++ b/src/celestia/celx.cpp @@ -21,7 +21,7 @@ #include "execution.h" #include #include -#include +#include #include "imagecapture.h" #include "url.h" diff --git a/src/celestia/celx_category.cpp b/src/celestia/celx_category.cpp index 1bdd8245..109915c1 100644 --- a/src/celestia/celx_category.cpp +++ b/src/celestia/celx_category.cpp @@ -1,5 +1,5 @@ -#include +#include #include "celx.h" #include "celx_internal.h" #include "celx_category.h" diff --git a/src/celestia/celx_celestia.cpp b/src/celestia/celx_celestia.cpp index 9b3a82cd..e955d9e3 100644 --- a/src/celestia/celx_celestia.cpp +++ b/src/celestia/celx_celestia.cpp @@ -9,7 +9,7 @@ // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. -#include +#include #include #include #include diff --git a/src/celestia/celx_misc.cpp b/src/celestia/celx_misc.cpp index 1105619c..f188d739 100644 --- a/src/celestia/celx_misc.cpp +++ b/src/celestia/celx_misc.cpp @@ -1,5 +1,5 @@ -#include +#include #include "celx_misc.h" #include "celx_internal.h" #include "cmdparser.h" diff --git a/src/celestia/cmdparser.cpp b/src/celestia/cmdparser.cpp index 089f378f..21617075 100644 --- a/src/celestia/cmdparser.cpp +++ b/src/celestia/cmdparser.cpp @@ -966,7 +966,7 @@ int parseConstellations(CommandConstellations* cmd, string s, int act) } else { - DPRINTF(0, "Command Parser: error parsing render flags\n"); + DPRINTF(LOG_LEVEL_ERROR, "Command Parser: error parsing render flags\n"); return 0; } } @@ -1006,7 +1006,7 @@ int parseConstellationColor(CommandConstellationColor* cmd, string s, Eigen::Vec } else { - DPRINTF(0, "Command Parser: error parsing render flags\n"); + DPRINTF(LOG_LEVEL_ERROR, "Command Parser: error parsing render flags\n"); return 0; } } diff --git a/src/celestia/configfile.cpp b/src/celestia/configfile.cpp index 0eb3ad6e..ab68c1e0 100644 --- a/src/celestia/configfile.cpp +++ b/src/celestia/configfile.cpp @@ -36,7 +36,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con ifstream configFile(filename.string()); if (!configFile.good()) { - DPRINTF(0, "Error opening config file '%s'.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "Error opening config file '%s'.\n", filename); return config; } @@ -45,14 +45,14 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con if (tokenizer.nextToken() != Tokenizer::TokenName) { - DPRINTF(0, "%s:%d 'Configuration' expected.\n", filename, + DPRINTF(LOG_LEVEL_ERROR, "%s:%d 'Configuration' expected.\n", filename, tokenizer.getLineNumber()); return config; } if (tokenizer.getStringValue() != "Configuration") { - DPRINTF(0, "%s:%d 'Configuration' expected.\n", filename, + DPRINTF(LOG_LEVEL_ERROR, "%s:%d 'Configuration' expected.\n", filename, tokenizer.getLineNumber()); return config; } @@ -60,7 +60,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con Value* configParamsValue = parser.readValue(); if (configParamsValue == nullptr || configParamsValue->getType() != Value::HashType) { - DPRINTF(0, "%s: Bad configuration file.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: Bad configuration file.\n", filename); return config; } @@ -132,7 +132,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con { if (solarSystemsVal->getType() != Value::ArrayType) { - DPRINTF(0, "%s: SolarSystemCatalogs must be an array.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: SolarSystemCatalogs must be an array.\n", filename); } else { @@ -148,7 +148,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con } else { - DPRINTF(0, "%s: Solar system catalog name must be a string.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: Solar system catalog name must be a string.\n", filename); } } } @@ -159,7 +159,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con { if (starCatalogsVal->getType() != Value::ArrayType) { - DPRINTF(0, "%s: StarCatalogs must be an array.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: StarCatalogs must be an array.\n", filename); } else { @@ -176,7 +176,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con } else { - DPRINTF(0, "%s: Star catalog name must be a string.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: Star catalog name must be a string.\n", filename); } } } @@ -187,7 +187,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con { if (dsoCatalogsVal->getType() != Value::ArrayType) { - DPRINTF(0, "%s: DeepSkyCatalogs must be an array.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: DeepSkyCatalogs must be an array.\n", filename); } else { @@ -204,7 +204,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con } else { - DPRINTF(0, "%s: DeepSky catalog name must be a string.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: DeepSky catalog name must be a string.\n", filename); } } } @@ -226,7 +226,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con } else { - DPRINTF(0, "%s: Extras directory name must be a string.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: Extras directory name must be a string.\n", filename); } } } @@ -236,7 +236,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con } else { - DPRINTF(0, "%s: ExtrasDirectories must be an array or string.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: ExtrasDirectories must be an array or string.\n", filename); } } @@ -245,7 +245,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con { if (ignoreExtVal->getType() != Value::ArrayType) { - DPRINTF(0, "%s: IgnoreGLExtensions must be an array.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: IgnoreGLExtensions must be an array.\n", filename); } else { @@ -259,7 +259,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con } else { - DPRINTF(0, "%s: extension name must be a string.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: extension name must be a string.\n", filename); } } } @@ -270,7 +270,7 @@ CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *con { if (starTexValue->getType() != Value::HashType) { - DPRINTF(0, "%s: StarTextures must be a property list.\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "%s: StarTextures must be a property list.\n", filename); } else { diff --git a/src/celestia/destination.cpp b/src/celestia/destination.cpp index 54fae68a..b5b044e3 100644 --- a/src/celestia/destination.cpp +++ b/src/celestia/destination.cpp @@ -28,7 +28,7 @@ DestinationList* ReadDestinationList(istream& in) { if (tokenizer.getTokenType() != Tokenizer::TokenBeginGroup) { - DPRINTF(0, "Error parsing destinations file.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Error parsing destinations file.\n"); for_each(destinations->begin(), destinations->end(), deleteFunc()); delete destinations; return nullptr; @@ -38,7 +38,7 @@ DestinationList* ReadDestinationList(istream& in) Value* destValue = parser.readValue(); if (destValue == nullptr || destValue->getType() != Value::HashType) { - DPRINTF(0, "Error parsing destination.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Error parsing destination.\n"); for_each(destinations->begin(), destinations->end(), deleteFunc()); delete destinations; if (destValue != nullptr) @@ -51,7 +51,7 @@ DestinationList* ReadDestinationList(istream& in) if (!destParams->getString("Name", dest->name)) { - DPRINTF(1, "Skipping unnamed destination\n"); + DPRINTF(LOG_LEVEL_INFO, "Skipping unnamed destination\n"); delete dest; } else diff --git a/src/celestia/favorites.cpp b/src/celestia/favorites.cpp index e088273f..abdabe7e 100644 --- a/src/celestia/favorites.cpp +++ b/src/celestia/favorites.cpp @@ -30,7 +30,7 @@ FavoritesList* ReadFavoritesList(istream& in) { if (tokenizer.getTokenType() != Tokenizer::TokenString) { - DPRINTF(0, "Error parsing favorites file.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Error parsing favorites file.\n"); for_each(favorites->begin(), favorites->end(), deleteFunc()); delete favorites; return nullptr; @@ -42,7 +42,7 @@ FavoritesList* ReadFavoritesList(istream& in) Value* favParamsValue = parser.readValue(); if (favParamsValue == nullptr || favParamsValue->getType() != Value::HashType) { - DPRINTF(0, "Error parsing favorites entry %s\n", fav->name.c_str()); + DPRINTF(LOG_LEVEL_ERROR, "Error parsing favorites entry %s\n", fav->name.c_str()); for_each(favorites->begin(), favorites->end(), deleteFunc()); delete favorites; if (favParamsValue != nullptr) diff --git a/src/celestia/imagecapture.cpp b/src/celestia/imagecapture.cpp index b66c0371..5c1426b0 100644 --- a/src/celestia/imagecapture.cpp +++ b/src/celestia/imagecapture.cpp @@ -44,7 +44,7 @@ bool CaptureGLBufferToJPEG(const fs::path& filename, #endif if (out == nullptr) { - DPRINTF(0, "Can't open screen capture file '%s'\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "Can't open screen capture file '%s'\n", filename); delete[] pixels; return false; } @@ -116,7 +116,7 @@ bool CaptureGLBufferToPNG(const fs::path& filename, #endif if (out == nullptr) { - DPRINTF(0, "Can't open screen capture file '%s'\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "Can't open screen capture file '%s'\n", filename); delete[] pixels; return false; } @@ -133,7 +133,7 @@ bool CaptureGLBufferToPNG(const fs::path& filename, if (png_ptr == nullptr) { - DPRINTF(0, "Screen capture: error allocating png_ptr\n"); + DPRINTF(LOG_LEVEL_ERROR, "Screen capture: error allocating png_ptr\n"); fclose(out); delete[] pixels; delete[] row_pointers; @@ -143,7 +143,7 @@ bool CaptureGLBufferToPNG(const fs::path& filename, info_ptr = png_create_info_struct(png_ptr); if (info_ptr == nullptr) { - DPRINTF(0, "Screen capture: error allocating info_ptr\n"); + DPRINTF(LOG_LEVEL_ERROR, "Screen capture: error allocating info_ptr\n"); fclose(out); delete[] pixels; delete[] row_pointers; @@ -153,7 +153,7 @@ bool CaptureGLBufferToPNG(const fs::path& filename, if (setjmp(png_jmpbuf(png_ptr))) { - DPRINTF(0, "Error writing PNG file '%s'\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "Error writing PNG file '%s'\n", filename); fclose(out); delete[] pixels; delete[] row_pointers; diff --git a/src/celestia/oggtheoracapture.cpp b/src/celestia/oggtheoracapture.cpp index 122a0e81..40864436 100644 --- a/src/celestia/oggtheoracapture.cpp +++ b/src/celestia/oggtheoracapture.cpp @@ -69,7 +69,7 @@ #include #include #include -#include +#include #include using namespace std; @@ -160,7 +160,7 @@ bool OggTheoraCapture::start(const std::string& filename, outfile = fopen(filename.c_str(), "wb"); if (!outfile) { - DPRINTF(0, _("Error in creating ogg file %s for capture.\n"), filename.c_str()); + DPRINTF(LOG_LEVEL_ERROR, _("Error in creating ogg file %s for capture.\n"), filename.c_str()); return false; } /* Set up Ogg output stream */ @@ -309,13 +309,14 @@ bool OggTheoraCapture::start(const std::string& filename, yuv.uv_height=video_y/2; yuv.uv_stride=video_x/2; - fmt::printf(_("OggTheoraCapture::start() - Theora video: %s %.2f(%d/%d) fps quality %d %dx%d offset (%dx%d)\n"), - filename.c_str(), - (double)video_hzn/(double)video_hzd, - video_hzn,video_hzd, - video_q, - video_x,video_y, - frame_x_offset,frame_y_offset); + DPRINTF(LOG_LEVEL_VERBOSE, + _("OggTheoraCapture::start() - Theora video: %s %.2f(%d/%d) fps quality %d %dx%d offset (%dx%d)\n"), + filename.c_str(), + (double)video_hzn/(double)video_hzd, + video_hzn,video_hzd, + video_q, + video_x,video_y, + frame_x_offset,frame_y_offset); capturing = true; return true; @@ -409,7 +410,7 @@ bool OggTheoraCapture::captureFrame() } video_frame_count += 1; //if ((video_frame_count % 10) == 0) - // fmt::printf("Writing frame %d\n", video_frame_count); + // DPRINTF(LOG_LEVEL_VERBOSE, "Writing frame %d\n", video_frame_count); unsigned char *temp = yuvframe[0]; yuvframe[0] = yuvframe[1]; yuvframe[1] = temp; @@ -424,7 +425,7 @@ void OggTheoraCapture::cleanup() if(outfile) { - fmt::printf(_("OggTheoraCapture::cleanup() - wrote %d frames\n"), video_frame_count); + DPRINTF(LOG_LEVEL_VERBOSE, _("OggTheoraCapture::cleanup() - wrote %d frames\n"), video_frame_count); if (video_frame_count > 0) { yuv.y= yuvframe[1]; diff --git a/src/celestia/url.cpp b/src/celestia/url.cpp index 712e731b..5a6b227e 100644 --- a/src/celestia/url.cpp +++ b/src/celestia/url.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include "celestiacore.h" #include "celutil/util.h" #include "celengine/astro.h" diff --git a/src/celmodel/modelfile.cpp b/src/celmodel/modelfile.cpp index 42bce0b0..2f3965dd 100644 --- a/src/celmodel/modelfile.cpp +++ b/src/celmodel/modelfile.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include using namespace cmod; diff --git a/src/celtxf/texturefont.cpp b/src/celtxf/texturefont.cpp index 7503790d..dd997954 100644 --- a/src/celtxf/texturefont.cpp +++ b/src/celtxf/texturefont.cpp @@ -222,7 +222,7 @@ bool TextureFont::buildTexture() glGenTextures(1, (GLuint*) &texName); if (texName == 0) { - DPRINTF(0, "Failed to allocate texture object for font.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Failed to allocate texture object for font.\n"); return false; } @@ -258,7 +258,7 @@ void TextureFont::rebuildGlyphLookupTable() // If there was already a lookup table, delete it. delete[] glyphLookup; - DPRINTF(1, "texturefont: allocating glyph lookup table with %d entries.\n", + DPRINTF(LOG_LEVEL_INFO, "texturefont: allocating glyph lookup table with %d entries.\n", maxID + 1); glyphLookup = new const Glyph*[maxID + 1]; for (int i = 0; i <= maxID; i++) @@ -322,7 +322,7 @@ TextureFont* TextureFont::load(istream& in) in.read(header, sizeof header); if (!in.good() || strncmp(header, "\377txf", 4) != 0) { - DPRINTF(0, "Stream is not a texture font!.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Stream is not a texture font!.\n"); return nullptr; } @@ -330,7 +330,7 @@ TextureFont* TextureFont::load(istream& in) in.read(reinterpret_cast(&endiannessTest), sizeof endiannessTest); if (!in.good()) { - DPRINTF(0, "Error reading endianness bytes in txf header.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Error reading endianness bytes in txf header.\n"); return nullptr; } @@ -341,7 +341,7 @@ TextureFont* TextureFont::load(istream& in) byteSwap = false; else { - DPRINTF(0, "Stream is not a texture font!.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Stream is not a texture font!.\n"); return nullptr; } @@ -354,11 +354,11 @@ TextureFont* TextureFont::load(istream& in) if (!in) { - DPRINTF(0, "Texture font stream is incomplete"); + DPRINTF(LOG_LEVEL_ERROR, "Texture font stream is incomplete"); return nullptr; } - DPRINTF(1, "Font contains %d glyphs.\n", nGlyphs); + DPRINTF(LOG_LEVEL_INFO, "Font contains %d glyphs.\n", nGlyphs); auto* font = new TextureFont(); assert(font != nullptr); @@ -385,7 +385,7 @@ TextureFont* TextureFont::load(istream& in) if (!in) { - DPRINTF(0, "Error reading glyph %ud from texture font stream.\n", i); + DPRINTF(LOG_LEVEL_ERROR, "Error reading glyph %ud from texture font stream.\n", i); delete font; return nullptr; } @@ -410,12 +410,12 @@ TextureFont* TextureFont::load(istream& in) { auto* fontImage = new unsigned char[texWidth * texHeight]; - DPRINTF(1, "Reading %d x %d 8-bit font image.\n", texWidth, texHeight); + DPRINTF(LOG_LEVEL_INFO, "Reading %d x %d 8-bit font image.\n", texWidth, texHeight); in.read(reinterpret_cast(fontImage), texWidth * texHeight); if (in.gcount() != (signed)(texWidth * texHeight)) { - DPRINTF(0, "Missing bitmap data in font stream.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Missing bitmap data in font stream.\n"); delete font; delete[] fontImage; return nullptr; @@ -429,12 +429,12 @@ TextureFont* TextureFont::load(istream& in) auto* fontBits = new unsigned char[rowBytes * texHeight]; auto* fontImage = new unsigned char[texWidth * texHeight]; - DPRINTF(1, "Reading %d x %d 1-bit font image.\n", texWidth, texHeight); + DPRINTF(LOG_LEVEL_INFO, "Reading %d x %d 1-bit font image.\n", texWidth, texHeight); in.read(reinterpret_cast(fontBits), rowBytes * texHeight); if (in.gcount() != (signed)(rowBytes * texHeight)) { - DPRINTF(0, "Missing bitmap data in font stream.\n"); + DPRINTF(LOG_LEVEL_ERROR, "Missing bitmap data in font stream.\n"); delete font; delete[] fontImage; delete[] fontBits; @@ -468,7 +468,7 @@ TextureFont* LoadTextureFont(const fs::path& filename) ifstream in(localeFilename.string(), ios::in | ios::binary); if (!in.good()) { - DPRINTF(0, "Could not open font file %s\n", filename); + DPRINTF(LOG_LEVEL_ERROR, "Could not open font file %s\n", filename); return nullptr; } diff --git a/src/celutil/bigfix.cpp b/src/celutil/bigfix.cpp index 8f343186..f0de0bc1 100644 --- a/src/celutil/bigfix.cpp +++ b/src/celutil/bigfix.cpp @@ -13,7 +13,7 @@ // of the License, or (at your option) any later version. #include -#include +#include #include #include "bigfix.h" @@ -255,11 +255,12 @@ int BigFix::sign() const // For debugging void BigFix::dump() { - fmt::printf("%08x %08x %08x %08x", - (uint32_t) (hi >> 32), - (uint32_t) (hi & 0xffffffff), - (uint32_t) (lo >> 32), - (uint32_t) (lo & 0xffffffff)); + DPRINTF(LOG_LEVEL_INFO, + "%08x %08x %08x %08x", + (uint32_t) (hi >> 32), + (uint32_t) (hi & 0xffffffff), + (uint32_t) (lo >> 32), + (uint32_t) (lo & 0xffffffff)); } @@ -277,10 +278,10 @@ int main(int argc, char* argv[]) if (sscanf(argv[2], "%lf", &b) != 1) return 1; - fmt::printf(" sum:\n%f\n%f\n", a + b, (double) (BigFix(a) + BigFix(b))); - fmt::printf(" diff:\n%f\n%f\n", a - b, (double) (BigFix(a) - BigFix(b))); - fmt::printf("product:\n%f\n%f\n", a * b, (double) (BigFix(a) * BigFix(b))); - fmt::printf(" lt: %u %u\n", a < b, BigFix(a) < BigFix(b)); + DPRINTF(LOG_LEVEL_INFO, " sum:\n%f\n%f\n", a + b, (double) (BigFix(a) + BigFix(b))); + DPRINTF(LOG_LEVEL_INFO, " diff:\n%f\n%f\n", a - b, (double) (BigFix(a) - BigFix(b))); + DPRINTF(LOG_LEVEL_INFO, "product:\n%f\n%f\n", a * b, (double) (BigFix(a) * BigFix(b))); + DPRINTF(LOG_LEVEL_INFO, " lt: %u %u\n", a < b, BigFix(a) < BigFix(b)); return 0; } diff --git a/src/celutil/debug.h b/src/celutil/debug.h index c5144747..09d6a976 100644 --- a/src/celutil/debug.h +++ b/src/celutil/debug.h @@ -20,6 +20,13 @@ #undef DPRINTF // OSX has DPRINTF #endif // DPRINTF +// verbosity choices +#define LOG_LEVEL_ERROR 0 +#define LOG_LEVEL_WARNING 1 +#define LOG_LEVEL_INFO 2 +#define LOG_LEVEL_VERBOSE 3 +#define LOG_LEVEL_DEBUG 4 + #if !defined(_DEBUG) && !defined(DEBUG) #define DPRINTF(level, format, ...) #else diff --git a/src/celutil/util.cpp b/src/celutil/util.cpp index e7a40d03..19699c9b 100644 --- a/src/celutil/util.cpp +++ b/src/celutil/util.cpp @@ -9,7 +9,7 @@ // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. -#include +#include #include "util.h" #ifdef _WIN32 #include