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

Author Topic: sf::err result what does it mean?  (Read 6346 times)

0 Members and 1 Guest are viewing this topic.

chrisciscoioio

  • Newbie
  • *
  • Posts: 17
    • View Profile
sf::err result what does it mean?
« on: October 28, 2012, 02:11:03 am »
this is the output of an sf::err - 6B63D240 

It looks like a memory address, is it not a useful string, I am missing something?                       

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10830
    • View Profile
    • development blog
    • Email
AW: sf::err result what does it mean?
« Reply #1 on: October 28, 2012, 02:21:25 am »
What are you trying to do? ???
What, when and how does sf::err do what and in which way?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

chrisciscoioio

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: sf::err result what does it mean?
« Reply #2 on: October 28, 2012, 02:34:00 am »
Output sf::err to a file like so.

static void Write(std::string message,std::ostream& stream)
        {
                if(isEnabled)
                {
                        std::fstream file;
                        file.open(logFile.c_str(), std::ios::out | std::ios::app);

                        if (file.is_open())
                        {
                                file << message;
                                file << stream;
                                file << "\n";
                                file.close();
                        }
               
                }
        }


This particular error comes from not being able to load an image, I know why it cannot load the image, so I am not trying to solve that issue, I am just trying to get my Logger working with sf::err like above.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10830
    • View Profile
    • development blog
    • Email
AW: sf::err result what does it mean?
« Reply #3 on: October 28, 2012, 02:36:12 am »
Well you are returning the address of the stream and that's what you're getting on the output. &x denotes: address of x. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

chrisciscoioio

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: sf::err result what does it mean?
« Reply #4 on: October 28, 2012, 02:42:27 am »
Where am I doing that?

maybe you caught a look at the code before I changed the code to what it should be.

Anyways how can I fix it so that I can output the stream after a string like in the code sample.

I tried following the redirect in the documentation but that causes the program to crash with a
Unhandled exception at 0x774a15de in Soaring Steele Prototype.exe: 0xC0000005: Access violation.
« Last Edit: October 28, 2012, 02:34:44 am by chrisciscoioio »

cire

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: sf::err result what does it mean?
« Reply #5 on: October 28, 2012, 02:48:08 am »
Why are you trying to write a std::ostream to your file?  Why does Write even take a std::ostream&, given the implementation?

chrisciscoioio

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: sf::err result what does it mean?
« Reply #6 on: October 28, 2012, 03:32:13 am »
sf::err is a ostream, I dont know how else to get the SFML error message.

That is a write function I only made to try and write out the sf::err, my normal one only takes string.

cire

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: sf::err result what does it mean?
« Reply #7 on: October 28, 2012, 06:09:06 am »
What exactly are you trying to do?  Writing a stream to another stream doesn't make much sense.

Are you trying to redirect sf::err to another stream?  That's covered in the documentation.

http://www.sfml-dev.org/documentation/2.0/group__system.php

chrisciscoioio

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: sf::err result what does it mean?
« Reply #8 on: October 28, 2012, 02:29:53 pm »
What exactly are you trying to do?  Writing a stream to another stream doesn't make much sense.

Are you trying to redirect sf::err to another stream?  That's covered in the documentation.

http://www.sfml-dev.org/documentation/2.0/group__system.php

Which crashes.... following the documentation code for code .

Edit: Or not? apparently setting it in the main doesnt crash it, but setting it in my Logger init does... o well, literally copy and paste between the two.
« Last Edit: October 28, 2012, 02:33:53 pm by chrisciscoioio »

chrisciscoioio

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: sf::err result what does it mean?
« Reply #9 on: October 28, 2012, 02:53:17 pm »
Follow up question, so it works, but only in certain cases in my code, if I wrap it in an if statement at all, it wont output to the file...

See the output, if I remove the if statement it will output to the file, if I leave it in all it will do is not print to the console but not output to the file.

// Enable Logging if in Debug Mode
        if(_DEBUG)
        {
                // Base Name, Enabled, Has Date
                Logger::Init("Soaring Steele",true,true);
        }
        else
        {
                // Base Name, Enabled, Has Date
                Logger::Init("Soaring Steele",false,true);
        }

        // Redirect the standard error to a file, if logging is enabled.
        // For some reason you cannt wrap an if statement around this or it fails to work right.
        // So comment out if you dont want the standard error going here.
        if(Logger::isEnabled)
       {
        std::ofstream file(Logger::logFile.c_str(), std::ios::app);
        std::streambuf* previous = sf::err().rdbuf(file.rdbuf());
        }

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: sf::err result what does it mean?
« Reply #10 on: October 28, 2012, 03:01:30 pm »
The "file" variable must not be destroyed as long as you use its rdbuf, because it's still the owner of it (and thus it destroys it when it goes out of scope).
Laurent Gomila - SFML developer

chrisciscoioio

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: sf::err result what does it mean?
« Reply #11 on: October 28, 2012, 05:13:50 pm »
heh, ya that's right, stupid mistake