Comments (5)
One option would be to not use TParticle::Print()
. Add operator<<
to TParticle
. Either by patching it in ROOT, or externally in your code, something like:
inline std::ostream& operator<<(std::ostream& os, const TParticle& p)
{
return os << "TParticle: " << p.GetName() << " " << p.Px() << " " << p.Py() << " " << p.Pz() << " " << p.Vx() << " " << p.Vy() << " " << p.Vz() << " " << p.GetFirstMother() << " " << p.GetMother();
}
After this you can change your code to:
TParticle *p = (TParticle *)tr->GetParticle();
LOG(info) << "Stage " << p->GetStatusCode() << " : " << *p;
That would give you the exact same output (unless I have a typo somewhere, but you can achieve it).
Or modify it to get the output you actually want. Like, the operator<<
could already include p.GetStatusCode()
, remove unneeded fields, etc..
from fairlogger.
We could also add another macro that doesn't add a new line.
from fairlogger.
There is also a problem with your code. If it is called from multiple threads, the output can become mixed. This would also be the case with the no-new-line-macro.
The operator<<
solution doesn't have this issue.
from fairlogger.
I think it would be good to have the "no-new-line-macro" because otherwise the output could look in some cases messy.
For p->Print()
I would go with your suggested solution of an operator<<
.
from fairlogger.
The "no-new-line-macro" will not happen because of the outlined potential for threading issues it may cause. Furthermore I would avoid adding any state that is stored between LOG calls in FairLogger. And finally, as Dennis correctly pointed out in one of our meetings - a call to LOG "adds an entry in the log", which makes a new line at the end appropriate.
from fairlogger.
Related Issues (15)
- Adopt find_package2 and generate_package_dependencies from FairMQ CMake
- Upstream functionalities in O2/Framework/Logger HOT 4
- Feature request: Make Logger non-global optionally HOT 1
- Add option to change name of the LOG macro
- -Wdangling-else
- Provide ostream based API HOT 1
- Exported FairLogger_INCDIR not relocatable HOT 1
- Missing v1.2.0 tag HOT 5
- Possibility to have a variable/expression as log level HOT 1
- Ability to only use the custom syncs? HOT 1
- Feature: Add new log severity `detail` between `info` and `debug` HOT 2
- FairLogger uses internal fmt version when asked to install, regardless of `-DUSE_EXTERNAL_FMT=ON` HOT 5
- a semicolon was inserted in the linker flags HOT 1
- Be able to customize verbosity information HOT 7
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 fairlogger.