« first day (2329 days earlier)      last day (748 days later) » 

02:08
Hey guys, how might I make a logger (through spdlog) that works across multiple files? Meaning, I have one .cpp (call it A) with the main function, but I want to log a lot of what's happening in another .cpp (call it B) file that the main one #includes into the main's log output.
My current best idea is to make a logger object in the constructor of the class in B that points to the same log file as A, but that seems ad hoc and I'm not sure if it will overwrite what is written by A. Any ideas?
Also, I noticed the last question I asked here got moved to another room more suited for questions, but I do not remember how to get there. Sorry in advance, whoever moves this conversation to the other room
 
6 hours later…
07:42
Hi, I have a question about multi-threading. My aim to store data from 26 large .csv files into 1 single vector. So I try to parallelize this by storing data from 1 file into a single vector in parallel then concatenate all the 26 vectors once all the single files are stored. The problem is that single threaded performance consistently outperforms the multi-threaded solution. Any advice on this?
Single threaded codes take ~500ms whereas the multi-threaded solution is much slower at ~700ms
measured using std::chrono::high_resolution_clock
 
2 hours later…
nwp
nwp
10:11
@Electrical_engineer_student Chances are that the disk speed is the limiting factor, not CPU speed. Multithreading gives you access to more cores but not to more disks. Various overheads such as thread creation, synchronization and the disk switching files probably explains the time difference.
3 messages moved from Lounge<C++>
@Catyre Logging should probably be a function, not an object. If you do make it an object make it global just like std::cout and qDebug().
 
4 hours later…
14:13
@nwp Sorry, I could not get your idea. Could you please explain that in more detail for me?
What does this mean?
enum class SampleType : Demo::Bar::SampleType {
Dog = 1,
Cat = 2,
};
The SampleType(i.e. uint8_t) could be inherited?
What a surprise!
15:08
nwp, I find the answer now.
But one more question arises. Your solution works for the simple case indeed. But for my project, it seems not a suitable one since there are still many public methods in the Demo::Foo and Demo::Bar classes. Once I use the derived classes instead of the base one(say Demo::Foo), I can't call the methods provided by the base class in my main function anymore.
How do you think about it? It's a bad idea to write the public methods provided by the base class again in the derived one. @nwp
 
2 hours later…
nwp
nwp
17:24
@John It's setting the underlying type which is somewhat different from inheriting, I think. You can't inherit from builtins and for an enum class you don't have access to the + operator that the underlying type would have. Also you cannot use other things like an std::string as the underlying type.
@John Inherit publicly, then you can. You only need to be careful with slicing where you pass a MyFoo into a function that takes a Demo::Foo. It will work, but strip away the MyFoo.

« first day (2329 days earlier)      last day (748 days later) »