From 98df6eae77d646eb8958ce39988d2c0c8da0b1ba Mon Sep 17 00:00:00 2001 From: cutealien Date: Thu, 30 Jun 2022 16:23:48 +0000 Subject: [PATCH] Unify & improve log messages Lots of places where coders did not realize our Printer::log with hint adds a ": " string between message and hint Which caused uglier messages in a few places (added documentation for that, maybe helps?) Some added info in a few places Some whitespace unification Some spelling unification git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6414 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CImageLoaderPNG.cpp | 12 ++++++------ source/Irrlicht/CImageLoaderTGA.cpp | 2 +- source/Irrlicht/CImageWriterPNG.cpp | 8 ++++---- source/Irrlicht/CIrrDeviceLinux.cpp | 16 ++++++++-------- source/Irrlicht/CIrrDeviceSDL.cpp | 4 ++-- source/Irrlicht/COBJMeshFileLoader.cpp | 2 +- source/Irrlicht/CSkinnedMesh.cpp | 12 ++++++------ source/Irrlicht/CWGLManager.cpp | 2 +- source/Irrlicht/CXMeshFileLoader.cpp | 4 ++-- source/Irrlicht/os.h | 2 ++ 10 files changed, 33 insertions(+), 31 deletions(-) diff --git a/source/Irrlicht/CImageLoaderPNG.cpp b/source/Irrlicht/CImageLoaderPNG.cpp index 59709bf..665634c 100644 --- a/source/Irrlicht/CImageLoaderPNG.cpp +++ b/source/Irrlicht/CImageLoaderPNG.cpp @@ -80,14 +80,14 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const // Read the first few bytes of the PNG file if( file->read(buffer, 8) != 8 ) { - os::Printer::log("LOAD PNG: can't read file\n", file->getFileName(), ELL_ERROR); + os::Printer::log("LOAD PNG: can't read file (filesize < 8)", file->getFileName(), ELL_ERROR); return 0; } // Check if it really is a PNG file if( png_sig_cmp(buffer, 0, 8) ) { - os::Printer::log("LOAD PNG: not really a png\n", file->getFileName(), ELL_ERROR); + os::Printer::log("LOAD PNG: not really a png (wrong signature)", file->getFileName(), ELL_ERROR); return 0; } @@ -96,7 +96,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const NULL, (png_error_ptr)png_cpexcept_error, (png_error_ptr)png_cpexcept_warn); if (!png_ptr) { - os::Printer::log("LOAD PNG: Internal PNG create read struct failure\n", file->getFileName(), ELL_ERROR); + os::Printer::log("LOAD PNG: Internal PNG create read struct failure", file->getFileName(), ELL_ERROR); return 0; } @@ -104,7 +104,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const png_infop info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - os::Printer::log("LOAD PNG: Internal PNG create info struct failure\n", file->getFileName(), ELL_ERROR); + os::Printer::log("LOAD PNG: Internal PNG create info struct failure", file->getFileName(), ELL_ERROR); png_destroy_read_struct(&png_ptr, NULL, NULL); return 0; } @@ -212,7 +212,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const image = new CImage(ECF_R8G8B8, core::dimension2d(Width, Height)); if (!image) { - os::Printer::log("LOAD PNG: Internal PNG create image struct failure\n", file->getFileName(), ELL_ERROR); + os::Printer::log("LOAD PNG: Internal PNG create image struct failure", file->getFileName(), ELL_ERROR); png_destroy_read_struct(&png_ptr, NULL, NULL); return 0; } @@ -221,7 +221,7 @@ IImage* CImageLoaderPng::loadImage(io::IReadFile* file) const RowPointers = new png_bytep[Height]; if (!RowPointers) { - os::Printer::log("LOAD PNG: Internal PNG create row pointers failure\n", file->getFileName(), ELL_ERROR); + os::Printer::log("LOAD PNG: Internal PNG create row pointers failure", file->getFileName(), ELL_ERROR); png_destroy_read_struct(&png_ptr, NULL, NULL); delete image; return 0; diff --git a/source/Irrlicht/CImageLoaderTGA.cpp b/source/Irrlicht/CImageLoaderTGA.cpp index 3286bdd..d5e24a5 100644 --- a/source/Irrlicht/CImageLoaderTGA.cpp +++ b/source/Irrlicht/CImageLoaderTGA.cpp @@ -106,7 +106,7 @@ IImage* CImageLoaderTGA::loadImage(io::IReadFile* file) const if (!checkImageDimensions(header.ImageWidth, header.ImageHeight)) { - os::Printer::log("Rejecting TGA with unreasonable size.", ELL_ERROR); + os::Printer::log("Image dimensions too large in file", file->getFileName(), ELL_ERROR); return 0; } diff --git a/source/Irrlicht/CImageWriterPNG.cpp b/source/Irrlicht/CImageWriterPNG.cpp index 0e2a71e..2f5260a 100644 --- a/source/Irrlicht/CImageWriterPNG.cpp +++ b/source/Irrlicht/CImageWriterPNG.cpp @@ -69,7 +69,7 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) NULL, (png_error_ptr)png_cpexcept_error, (png_error_ptr)png_cpexcept_warning); if (!png_ptr) { - os::Printer::log("PNGWriter: Internal PNG create write struct failure\n", file->getFileName(), ELL_ERROR); + os::Printer::log("PNGWriter: Internal PNG create write struct failure", file->getFileName(), ELL_ERROR); return false; } @@ -77,7 +77,7 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) png_infop info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - os::Printer::log("PNGWriter: Internal PNG create info struct failure\n", file->getFileName(), ELL_ERROR); + os::Printer::log("PNGWriter: Internal PNG create info struct failure", file->getFileName(), ELL_ERROR); png_destroy_write_struct(&png_ptr, NULL); return false; } @@ -126,7 +126,7 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) u8* tmpImage = new u8[image->getDimension().Height*lineWidth]; if (!tmpImage) { - os::Printer::log("PNGWriter: Internal PNG create image failure\n", file->getFileName(), ELL_ERROR); + os::Printer::log("PNGWriter: Internal PNG create image failure", file->getFileName(), ELL_ERROR); png_destroy_write_struct(&png_ptr, &info_ptr); return false; } @@ -160,7 +160,7 @@ bool CImageWriterPNG::writeImage(io::IWriteFile* file, IImage* image,u32 param) u8** RowPointers = new png_bytep[image->getDimension().Height]; if (!RowPointers) { - os::Printer::log("PNGWriter: Internal PNG create row pointers failure\n", file->getFileName(), ELL_ERROR); + os::Printer::log("PNGWriter: Internal PNG create row pointers failure", file->getFileName(), ELL_ERROR); png_destroy_write_struct(&png_ptr, &info_ptr); delete [] tmpImage; return false; diff --git a/source/Irrlicht/CIrrDeviceLinux.cpp b/source/Irrlicht/CIrrDeviceLinux.cpp index b447015..3c19099 100644 --- a/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/source/Irrlicht/CIrrDeviceLinux.cpp @@ -287,26 +287,26 @@ void IrrPrintXGrabError(int grabResult, const c8 * grabCommand ) { if ( grabResult == GrabSuccess ) { -// os::Printer::log(grabCommand, ": GrabSuccess", ELL_INFORMATION); +// os::Printer::log(grabCommand, "GrabSuccess", ELL_INFORMATION); return; } switch ( grabResult ) { case AlreadyGrabbed: - os::Printer::log(grabCommand, ": AlreadyGrabbed", ELL_WARNING); + os::Printer::log(grabCommand, "AlreadyGrabbed", ELL_WARNING); break; case GrabNotViewable: - os::Printer::log(grabCommand, ": GrabNotViewable", ELL_WARNING); + os::Printer::log(grabCommand, "GrabNotViewable", ELL_WARNING); break; case GrabFrozen: - os::Printer::log(grabCommand, ": GrabFrozen", ELL_WARNING); + os::Printer::log(grabCommand, "GrabFrozen", ELL_WARNING); break; case GrabInvalidTime: - os::Printer::log(grabCommand, ": GrabInvalidTime", ELL_WARNING); + os::Printer::log(grabCommand, "GrabInvalidTime", ELL_WARNING); break; default: - os::Printer::log(grabCommand, ": grab failed with unknown problem", ELL_WARNING); + os::Printer::log(grabCommand, "grab failed with unknown problem", ELL_WARNING); break; } } @@ -380,7 +380,7 @@ bool CIrrDeviceLinux::createWindow() } #ifdef _DEBUG else - os::Printer::log("Visual chosen: ", core::stringc(static_cast(VisualInfo->visualid)).c_str(), ELL_DEBUG); + os::Printer::log("Visual chosen", core::stringc(static_cast(VisualInfo->visualid)).c_str(), ELL_DEBUG); #endif // create color map @@ -1796,7 +1796,7 @@ Bool PredicateIsEventType(Display *display, XEvent *event, XPointer arg) { if ( event && event->type == *(int*)arg ) { -// os::Printer::log("remove event:", core::stringc((int)arg).c_str(), ELL_INFORMATION); +// os::Printer::log("remove event", core::stringc((int)arg).c_str(), ELL_INFORMATION); return True; } return False; diff --git a/source/Irrlicht/CIrrDeviceSDL.cpp b/source/Irrlicht/CIrrDeviceSDL.cpp index 711cb56..26683a7 100644 --- a/source/Irrlicht/CIrrDeviceSDL.cpp +++ b/source/Irrlicht/CIrrDeviceSDL.cpp @@ -220,7 +220,7 @@ CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param) #endif if (SDL_Init(flags) < 0) { - os::Printer::log( "Unable to initialize SDL!", SDL_GetError()); + os::Printer::log("Unable to initialize SDL!", SDL_GetError()); Close = true; } else @@ -447,7 +447,7 @@ bool CIrrDeviceSDL::createWindow() } if ( !Window ) { - os::Printer::log( "Could not initialize display!" ); + os::Printer::log("Could not initialize display!" ); return false; } diff --git a/source/Irrlicht/COBJMeshFileLoader.cpp b/source/Irrlicht/COBJMeshFileLoader.cpp index 740f8e5..43ea51e 100644 --- a/source/Irrlicht/COBJMeshFileLoader.cpp +++ b/source/Irrlicht/COBJMeshFileLoader.cpp @@ -224,7 +224,7 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file) v.Pos = vertexBuffer[Idx[0]]; else { - os::Printer::log("Invalid vertex index in this line:", wordBuffer.c_str(), ELL_ERROR); + os::Printer::log("Invalid vertex index in this line", wordBuffer.c_str(), ELL_ERROR); delete [] buf; return 0; } diff --git a/source/Irrlicht/CSkinnedMesh.cpp b/source/Irrlicht/CSkinnedMesh.cpp index f7cf1f0..75e2ca6 100644 --- a/source/Irrlicht/CSkinnedMesh.cpp +++ b/source/Irrlicht/CSkinnedMesh.cpp @@ -1134,27 +1134,27 @@ void CSkinnedMesh::finalize() if ( redundantPosKeys > 0 ) { - os::Printer::log("Skinned Mesh - redundant position frames kicked:", core::stringc(redundantPosKeys).c_str(), ELL_DEBUG); + os::Printer::log("Skinned Mesh - redundant position frames kicked", core::stringc(redundantPosKeys).c_str(), ELL_DEBUG); } if ( unorderedPosKeys > 0 ) { - irr::os::Printer::log("Skinned Mesh - unsorted position frames kicked:", irr::core::stringc(unorderedPosKeys).c_str(), irr::ELL_DEBUG); + irr::os::Printer::log("Skinned Mesh - unsorted position frames kicked", irr::core::stringc(unorderedPosKeys).c_str(), irr::ELL_DEBUG); } if ( redundantScaleKeys > 0 ) { - os::Printer::log("Skinned Mesh - redundant scale frames kicked:", core::stringc(redundantScaleKeys).c_str(), ELL_DEBUG); + os::Printer::log("Skinned Mesh - redundant scale frames kicked", core::stringc(redundantScaleKeys).c_str(), ELL_DEBUG); } if ( unorderedScaleKeys > 0 ) { - irr::os::Printer::log("Skinned Mesh - unsorted scale frames kicked:", irr::core::stringc(unorderedScaleKeys).c_str(), irr::ELL_DEBUG); + irr::os::Printer::log("Skinned Mesh - unsorted scale frames kicked", irr::core::stringc(unorderedScaleKeys).c_str(), irr::ELL_DEBUG); } if ( redundantRotationKeys > 0 ) { - os::Printer::log("Skinned Mesh - redundant rotation frames kicked:", core::stringc(redundantRotationKeys).c_str(), ELL_DEBUG); + os::Printer::log("Skinned Mesh - redundant rotation frames kicked", core::stringc(redundantRotationKeys).c_str(), ELL_DEBUG); } if ( unorderedRotationKeys > 0 ) { - irr::os::Printer::log("Skinned Mesh - unsorted rotation frames kicked:", irr::core::stringc(unorderedRotationKeys).c_str(), irr::ELL_DEBUG); + irr::os::Printer::log("Skinned Mesh - unsorted rotation frames kicked", irr::core::stringc(unorderedRotationKeys).c_str(), irr::ELL_DEBUG); } } diff --git a/source/Irrlicht/CWGLManager.cpp b/source/Irrlicht/CWGLManager.cpp index 0d7ef42..4cd6ea8 100644 --- a/source/Irrlicht/CWGLManager.cpp +++ b/source/Irrlicht/CWGLManager.cpp @@ -464,7 +464,7 @@ bool CWGLManager::activateContext(const SExposedVideoData& videoData, bool resto { if (!wglMakeCurrent((HDC)PrimaryContext.OpenGLWin32.HDc, (HGLRC)PrimaryContext.OpenGLWin32.HRc)) { - os::Printer::log("Render Context switch failed."); + os::Printer::log("Render Context switch (back to main) failed."); return false; } CurrentContext=PrimaryContext; diff --git a/source/Irrlicht/CXMeshFileLoader.cpp b/source/Irrlicht/CXMeshFileLoader.cpp index 2a365ac..c06cd17 100644 --- a/source/Irrlicht/CXMeshFileLoader.cpp +++ b/source/Irrlicht/CXMeshFileLoader.cpp @@ -479,7 +479,7 @@ bool CXMeshFileLoader::parseDataObject() // parse specific object #ifdef _XREADER_DEBUG - os::Printer::log("debug DataObject:", objectName.c_str(), ELL_DEBUG); + os::Printer::log("debug DataObject", objectName.c_str(), ELL_DEBUG); #endif if (objectName == "template") @@ -832,7 +832,7 @@ bool CXMeshFileLoader::parseDataObjectMesh(SXMesh &mesh) } #ifdef _XREADER_DEBUG - os::Printer::log("debug DataObject in mesh:", objectName.c_str(), ELL_DEBUG); + os::Printer::log("debug DataObject in mesh", objectName.c_str(), ELL_DEBUG); #endif if (objectName == "MeshNormals") diff --git a/source/Irrlicht/os.h b/source/Irrlicht/os.h index c0aa83b..dc1a154 100644 --- a/source/Irrlicht/os.h +++ b/source/Irrlicht/os.h @@ -38,6 +38,8 @@ namespace os static void print(const c8* message, ELOG_LEVEL ll = ELL_INFORMATION); static void log(const c8* message, ELOG_LEVEL ll = ELL_INFORMATION); static void log(const wchar_t* message, ELOG_LEVEL ll = ELL_INFORMATION); + + // The string ": " is added between message and hint static void log(const c8* message, const c8* hint, ELOG_LEVEL ll = ELL_INFORMATION); static void log(const c8* message, const io::path& hint, ELOG_LEVEL ll = ELL_INFORMATION); static ILogger* Logger;