Comments (8)
I tried the following commands on my machine, and they work as intended:
argos3 -l /dev/null -c experiments/diffusion_1.argos
argos3 --log-file /dev/null -c experiments/diffusion_1.argos
from argos3.
Found the issue! The specific use case I was targeting was when I get the library name wrong for either the controller or the loop functions, and ARGoS doesn't start. In those cases, I still want ARGoS to only return non-zero, and not print anything to the screen. However, when the library name is wrong ARGoS will throw an uncaught exception. If I do :
LOG << "some text" << std::endl
Anywhere before or after the library fails to load and things ultimately crash, it is silent. However, if I do:
LOGERR << "some text" << std::endl
Then I still see the text when the exception prints. I imagine its being buffered (and not yet set to /dev/null), and when the exception prints that mechanism takes anything that was queued up for stderr and prints it to the terminal. I don't see the text if I call Flush()
before the exception triggers.
I think the easy part of the solution here is to update the man page so that it's clear users can't do --log-file=/some-file
on --logerr-file=/other/file
(it currently says they can). For the other part, I think its reasonable as a user to assume that if you set the stderr logfile to something via --logerr-file
that everything that would come out on stderr should go to it, including exceptions. I'm not really sure how to implement this though. If this can't be implemented/would require too many changes, then the man page should be updated to say that ARGoS will still print exceptions on startup even when --logerr-file
is passed.
from argos3.
Are you using a custom main.cpp
file?
In the original main.cpp the log redirection is set before the libraries are loaded (see here), so the errors, in theory, should be redirected to /dev/null
.
from argos3.
Yes, I'm currently using the latest ARGoS master. I also tried with a normal file (/tmp/foo.txt
), and saw the same result, so it's not an issue with redirecting to a special system file. I'm on ubuntu 20.04, if that makes a difference.
from argos3.
Maybe we can add a Flush()
, as you suggested, just after the command line arguments are parsed. Can you try adding the following code:
#ifdef ARGOS_THREADSAFE_LOG
LOG.Flush();
LOGERR.Flush();
#endif
at the end of this method?
from argos3.
That didn't change anything, but it got me to the answer. LOG and LOGERR wrap std::cout
and std::cerr
, which are different than stdout
and stderr
(the C file descriptors). When exceptions are printed, they apparently get printed to stderr
, not to std::cerr
.
Adding the following to argos_command_line_arg_parser.cpp:113
right after the redirection for std::cerr
works:
freopen(m_strLogErrFileName.c_str(), "w", stderr);
similarly for stdout
. With these and no other changes, ARGoS is indeed silent when the redirection options are passed.
from argos3.
Great! Thanks for looking into this. Feel free to make a pull request for this fix when you have the time.
from argos3.
Opened #209, closing this.
from argos3.
Related Issues (20)
- Compiling the e-puck plugin for argos3 59 HOT 5
- No package 'argos3_simulator' found HOT 2
- ARGoS Checkpointing
- enh/actuator-enable-disable-interface
- Issue in building the doc in installation with Eclipse HOT 1
- gl.h not found in Mac OSX 11.4 Big Sur HOT 1
- Increasing the # cameras in ARGoS HOT 5
- EmodiedEntity init is called before successful place HOT 2
- bugfix/34/stderr-redirect
- Black screen HOT 3
- Physics of gripping with the foot-bot
- Install MacOS glut not found HOT 9
- Not using threads on WSL2 (Windows 11) HOT 2
- Bugs and usability of ARGoS drone HOT 3
- footbot_encoder can not be reading. HOT 3
- include could not find requested file: ARGoSCheckQTOpenGL HOT 1
- argos visualization error when running CPFA: cannot find CPFA_qt_user_functions on Ubuntu 22.04 LTS HOT 1
- [Fatal] Can't load library "/usr/lib/argos3/libargos3plugin_simulator_media.so"...undefined symbol HOT 1
- How to dynamically create LEDs detectable by an omnidirectional camera HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from argos3.