Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Redirection of cerr doesn't do anything to SFML errors  (Read 2579 times)

0 Members and 1 Guest are viewing this topic.

eriksvedang

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • http://www.eriksvedang.com
Redirection of cerr doesn't do anything to SFML errors
« on: October 19, 2009, 09:27:42 am »
Hi!

I'm working on a game using SFML 1.5 on Mac OS X Snow Leopard. It goes fine (great library!) but I have two problems I can't find a solution to:

1. I have redirected std::cerr to my log file so that error messages should be saved there instead of printed to the console. This is the code for that:

Code: [Select]
std::cerr.rdbuf(logFile.rdbuf());

If i use cerr myself it works fine, like this:

Code: [Select]
cerr << "An error occurred!";

But when something goes wrong in SFML (loading of a non-existent file for example) it is still printed to the console and not saved in the file. Does anyone know why?

2. My other problem is that when i start the project from XCode it is run from the Debug folder in my project and everything works fine. If I instead start the application from the finder it uses my root folder as the running folder! That of course messes up all paths to resources etc. Does anyone know how to fix this?

Thanks,
Erik

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Redirection of cerr doesn't do anything to SFML errors
« Reply #1 on: October 19, 2009, 10:11:26 am »
Hi

1. Some error messages do not come directly from SFML, but from external libraries used by SFML. In this case, I can't make sure that they are all printed to std::cerr. But maybe I can redirect them, what message did you get outside std::cerr?
Laurent Gomila - SFML developer

eriksvedang

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • http://www.eriksvedang.com
Redirection of cerr doesn't do anything to SFML errors
« Reply #2 on: October 19, 2009, 11:46:28 am »
Ok, that makes sense. Right now it's the loading of a font which gives the following error message:

Quote
Failed to load font "fonts/ArialBold.ttf" (cannot open resource)


Since the console isn't showing when I start the app from the finder it would be nice to be able to present these error messages through the log file instead of just showing nothing (and quitting).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Redirection of cerr doesn't do anything to SFML errors
« Reply #3 on: October 19, 2009, 12:14:41 pm »
It's weird, this message is generated by SFML and is properly sent to std::cerr.

Can you provide a sample program that produces this problem?
Laurent Gomila - SFML developer