C++ logging framework suggestions [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking for a C++ logging framework with the following features:
logs have a severity (info, warning, error, critical, etc)
logs are tagged with a module name
framework has a UI (or CLI) to configure for which modules we will actually log to file, and the minimum severity required for a log to be written to file.
has a viewer which lets me search per module, severity, module name, error name, etc

Not sure about the configuration from a UI or CLI. I've used both of these logging frameworks at one point or other.
https://sourceforge.net/projects/log4cplus/
https://logging.apache.org/log4cxx/index.html
It wouldn't be too hard to drive your logging based on a configuration file that could be editable by hand or through a quick and dirty GUI or CLI app. Might be a bit harder to adjust these dynamically but not too bad.
Update:
It looks like the proposed Boost.Log is now in Boost 1.54 which is at a stable release. If you are already using Boost than I would take a look at it.

No viewer but you could try pantheios. I have been using it for almost a year now and am quite happy with it.

I strongly suggest Pantheios, as it's the only one that's completely type-safe, and is also very efficient. It imposes a little work on the user, in selecting the right "front-end" and "back-end", but once you've got it working, you can just fix and forget.
It doesn't provide sophisticated logging facilities - e.g. rolling files - but that's by design, because it's intended to be used in combination with other logging libraries that have more functionality (but poorer performance / type-safety).

If you care about performance, I suggest you check out Pantheios. In particular, it's got very high performance, and it can be used in combination with other logging libraries -- it acts as an efficient and type-safe layer between the logging library (such as log4cxx) and your application code.

You could use wxWidgets and use it's excellent class for logging. It's rather easy and straightforward. For instance, you can create a dialog which gathers all your logs (e.g. wxLogError, wxLogMessage, wxLogDebug, etc.).

Pantheios is a good candidate in term of perormance but my personal preference is P7 library.
My internal tests (CPU i7-4870HQ, SSD) shows that P7 is faster than Pantheios.
Pantheios writes 1.8M logs lines per second (time & text message)
P7 writes 2.4M logs lines per second (time, thread, CPU core, function, file, line and text message)

Related

Is there a disassembler with modification and reassembly capabilities for a 32-bit executable? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I have a class project where we need to take a 32-bit executable written in C++ and disassemble it and modify the assembly code and then reassemble it. We're supposed to do things like hardcode cheats into the game.
I've been searching for hours and I can't find any software that will do this. I've looked at Ollydbg and spent about two hours with it and couldn't really figure out how to get it to work. I utilized Cheat Engine and that actually worked out really well for me - I was able to isolate the code modifying the addresses I cared about and replace it with code to have a favorable impact on the game, but as far as I can tell Cheat Engine has no ability to recompile the modified code.
This is a fairly lower level Computer Science class so please take into account my ability level when making suggestions but if there is any software out there or alternative ways that will allow me to do this I would greatly appreciate it. Thanks!
Since you mentioned OllyDBG and Cheat Engine I'm going to assume you're using Windows.
First, you can use OllyDBG to save a file, but for some reason I can't find this option in OllyDBG 2, only in older versions (like 1.10). You can right-click on the code window and then copy to executable > all modifications, A new window will open, right-click on the new window and then choose save file.
An alternative that I really like is x64dbg. it's an open source debugger/disassembler and has an option to save changes via "Patches".
Another option is to apply the changes via an hex editor, which allows you to modify any file (including executables) in a binary format. It is, of course, a bit harder to do since you need to translate your changes to op-codes manually, but if your changes are not too big or only consisting of modifying some constants it can be a faster and easier solution. There are a lot of hex editors out there but my favorite is XVI32.
What I personally like to do is to modify the memory via code using Windows API's WriteProcessMemory and ReadProcessMemory since it allows you to do this things dynamically.

What is the meaning and purpose of a logging library? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to understand the basics of a logging library.
What exactly is the purpose of a logging library? I understand that a log is basically information about your application process during execution. One way to do it is by writing information in a file directly.
What is the purpose of designing a dedicated library such as glog for logging purposes?
Is my understanding of logging correct, or do I need to change it?
Can someone give a practical example to exhibit the importance of using a logging library?
What features should one look at while choosing a logging library?
How can logging be effectively employed during implementations?
Logging information during the execution of your application can help you understand what led to a bug or crash, giving you more context than you get from simply a report of a crash, a call stack or even a minidump. This is particularly important when you are getting bug or crash reports from people who are not developers and are not running under a debugger, either end users / customers or non-developers on your team.
My background is in games and logging can be particularly valuable with games for a few reasons. One is that many issues can relate to the specifics of the hardware on a system so logging information like what kind of GPU the user has, which graphics driver version they are running, etc. can be essential to debugging problems that only show up on a specific configuration. Another is that games have a simulation aspect where the state of the game is evolving over time in response to user input combined with simulation of things like physics, AI and the game rules. Understanding what was going on in the run up to a crash or bug helps figure out how to reproduce it and can give valuable clues to the root cause of the issue.
A logging library adds functionality that is useful for logging and goes beyond what is available from a simple printf. This includes things like:
The ability to control the amount of logging based on factors like debug vs. release builds and runtime settings like a -verbose flag.
The concept of 'channels' that can be independently enabled, disabled or set to a particular verbosity. For example, to debug a graphics issue you may want the 'graphics' channel set to maximum verbosity while muting the 'network' and 'audio' channels.
A flexible back end ranging from logging to a local file on disk to logging to a remote database over a network.
Thread safety so that logging behaves itself when potentially logging simultaneously from multiple different threads.
Automatic tagging of log entries with a timestamp and any other relevant information (channel, verbosity level, etc.).
As for how to make use of a logging library, that is somewhat dependent on your application, but here's some general suggestions:
Make good use of channels and verbosity levels if your logging library provides them (and it should). This will help you manage what can become a very large volume of log messages as your application grows.
If you encounter an unexpected but non-fatal condition and handle it, log some information about it in case it leads to unforeseen problems later on.
On application startup, log any information that might come in useful for reproducing rare errors later if you receive a bug or crash report from a customer. Err on the side of too much information, you never know what might be useful in advance. This might include things like CPU type, GPU model and driver version, available memory, OS version, available hard drive space, etc.
Log key state transitions so you can track what state your application was in and how it got there when you are debugging an issue.
A lot of programs use some sort of logging, and there is little point to re-inventing the wheel every time, even if the code is relatively simple.
Other libraries can use the logging library too, so instead of having to configure the log files for each library you include in a project, you can just configure the one logging library. This also means that any bugs that might appear in the logging code can be fixed by just replacing the one library instead of having to replace multiple libraries.
Finally, it makes code easier to read for other developers because they don't have to figure out how you implemented your custom logging.

Doc string facility in C++ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Languages like Python, MATLAB, E-Lisp have this nice facility for doc-strings.
With this feature using just a few keystrokes in the terminal, you can fetch the documentations of the functions / module you have written and imported into your code.
Now is there any "technique" (library, Editor tricks , whatever to ) to get a similar facility in
C++ / C. Suppose I include the documentation of the function within the source file at
the head of the function,
then I would like to type a command like getinfo at the terminal. (something
like a man page)
I know such a 'man' facility exists for many C functions, but the documentation for these functions are written in separate text files from the source code. I would like the
documentation to be in-place
You can use something like doxygen. It has support for generating man pages, among other formats.
Visual Studio can/will generate popups containing information extracted from DocXml formatted comments. You have to compile with /doc, which will extract the XML from the comments to a .xdc file. Then you have to run xdcmake to compile the .xdc files into an xml file. You'd typically handle all this automatically in the build process, so you don't have to do much manually (except write the comments themselves, of course). The one thing to keep in mind, however, is that the code (at least a declaration) has to build before you get the popups.
I feel obliged to add that IMO, most such comments are generally pretty close to useless. If a corporate standard makes them unavoidable, so be it -- but if they're honestly providing any useful information, I'd consider that an indication of a problem ("Code smell", if you prefer that wording). In most cases, the combination of the name of the function (or whatever) and the names/types of the parameters should make the use of the function quite clear.
If you notate your code with comments in a syntax similar to Javadoc, you can generate a documentation for your code, in various different formats, using Doxygen. It can generate, among other things, man pages, but it seems that the preferred output format people use is HTML pages.

C++ code dependency / call-graph "viewer"? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
is there such a thing as a (free) tool that would display a graph of all functions call in a given function?
For instance, if I use it on a complex function fun() I'm trying to understand, it would show me all the functions called by fun() in order, then I would have the possibility to see the same thing for the function called by fun(), and so on.
I'm looking for this for C++ code.
Does such a thing even exist?
edit : I am using VS 2008 if that helps, but I was thinking that such a software would work on the source files anyway
Doxygen can do this. See the CALL_GRAPH configuration option:
If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will generate a call dependency graph for every global function or class method. Note that enabling this option will significantly increase the time of a run. So in most cases it will be better to enable call graphs for selected functions only using the \callgraph command.
Yes, Eclipse CDT Call Hierarchy view provides exactly this. Moreover, this view has 2 options:
Show Callers
Show Callees
You are asking about second one, but I am prefer the first one in code analysis.
Intel(R) Single Event API is free open-source project that utilises GraphVis for call-graph visualisation. It takes a bit of labour to do manual or compiler-automated instrumentation, but beside statistics and call-graphs you will get the overtime views as well.
Yes such things exist. Google under the heading static code analysis. There are, for example, tools such as Understand, and it is extremely likely that your compiler can do this too for which I refer you to its documentation.
You can use callgrind, and it's GUI tool kcachegrind.
I don't know of any tool specially desgined for this. However, there are a few ways of doing it:
Using a IDE (QtCreator is free, Visual Studio Express might also be helpful, Eclipse CDT)
Using (ctags)[http://ctags.sourceforge.net/] and a able text editor.
Using callgrind and the several views it brings. Advantage: you get to see the functions that are really called. Disadvantage: only runs in unixes, and you have to profile.
Using Doxygen... this one is really fancy, as it generates an html "view" of your code, provided that you supply the correct options.
g++ and most compilers can do what you want. It is called profiling. Also there is the oprofile. A profiler gives you the call graph of an application after its execution. This is very useful to study code, you can also walk through the [debug] output as you look at the graph. A code analyzer, in contrast, will give you all possible call paths however, you will not be able to see the significant path easily.
VC++2008/2010 profiler generates among others the file *CallerCalleeSummary.csv, that contains this information. And this is the link to the article explaining how to use it with sample program: Profiling of C++ Applications in Visual Studio

Good free profiler that supports MingW32 please? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I asked in another thread, how to profile my stuff, and people gave me lots of good replies, except that when I tried to use several of free profilers, including AMD Codeanalyst for example, they only support Microsoft PDB format, and MingW is unable to generate those.
So, what profiler can help me profile a multi-threaded application with Lua scripting and is compiled with MingW?
EDIT: gprof is crap, the awnser that says why I don't want it, is right on the spot... If I get all the functions that it litsts as troublesome, NONE of them are related to the issue that I have (there are a certain action that causes a massive slowdown, and I can't figure why, and gprof can't figure it either)
If you don't want to use gprof, I'm not surprised.
It took me a while to figure out how to do this under GDB, but here's what I do. Get the app running and change focus to the app's output window, even if it's only a DOS-box. Then I hit the Control-Break key (while it's being slow). Then GDB halts and I do info threads and it tells me what threads there are, typically 1 and 2. I switch to the thread I want, like thread 2. Then I do bt to see a stack trace. This tells me exactly what it was doing when I hit Control-Break. I do this a number of times, like 10 or 20, and if there's a performance problem, no matter what it is, it shows up on multiple samples of the stack. The slower it makes the program, the fewer samples I have to take before I see it.
For a complete analysis of how and why it works, see that link.
P.S. I also do handle SIGINT stop print nopass when I start GDB.
Does gprof not do it?
I thought MingW provided a gprof version to go with it.
If you want to profile Lua scripting, I could suggest using the LuaProfiler: http://luaprofiler.luaforge.net/manual.html. It works quite nicely.
I would strongly suggest implementing some sort of timers or your own profiler to get a simple profiling tool. A really simple one is to just output the times when certain points in your code is hit, output those times into a textfile and then write a simple lua or python script to parse the file and filter the interesting information.
I've used this (or a slightly more complex) version of profiling for most of my hobby-projects and it has proven very helpful.