Giter Club home page Giter Club logo

Comments (5)

rbx avatar rbx commented on August 16, 2024

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.

rbx avatar rbx commented on August 16, 2024

We could also add another macro that doesn't add a new line.

from fairlogger.

rbx avatar rbx commented on August 16, 2024

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.

TobiasStockmanns avatar TobiasStockmanns commented on August 16, 2024

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.

rbx avatar rbx commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.