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
This commit is contained in:
cutealien 2022-06-30 16:23:48 +00:00 committed by sfan5
parent 3ce4b2b5dc
commit 98df6eae77
10 changed files with 33 additions and 31 deletions

View File

@ -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<u32>(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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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<u32>(VisualInfo->visualid)).c_str(), ELL_DEBUG);
os::Printer::log("Visual chosen", core::stringc(static_cast<u32>(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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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")

View File

@ -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;