Logging library for (c++) games

Klaim
  • Logging library for (c++) games Klaim

    I know a lot of logging libraries but didn't test a lot of them. (GoogleLog, Pantheios, the coming boost::log library...)

    In games, especially in remote multiplayer and multithreaded games, logging is vital to debugging, even if you remove all logs in the end.

    Let's say I'm making a PC game (not console) that needs logs (multiplayer and multithreaded and/or multiprocess) and I have good reasons for looking for a library for logging (like, I don't have time or I'm not confident in my ability to write one correctly for my case).

    Assuming that I need :

    1. performance
    2. ease of use (allow streaming or formating or something like that)
    3. reliable (don't leak or crash!)
    4. cross-platform (at least Windows, MacOSX, Linux/Ubuntu)

    Wich logging library would you recommand?

    Currently, I think that boost::log is the most flexible one (you can even log to remotely!), but have not good performance update: is for high performance, but isn't released yet. Pantheios is often cited but I don't have comparison points on performance and usage. I've used my own lib for a long time but I know it don't manage multithreading so it's a big problem, even if it's fast enough. Google Log seems interesting, I just need to test it but if you already have compared those libs and more, your advice might be of good use.

    Games are often performance demanding while complex to debug so it would be good to know logging libraries that, in our specific case, have clear advantages.

  • When it comes to performance, I've found templog pretty much unbeaten. It uses expression templates to defer evaluation of logging statements until it's established that the information will be logged at all. Since you can also partly turn off logging (depending on severity, origin, and targeted audience of a log message), some of these logging statement can be eliminated to zero code by the compiler for release builds. (I have actually seen this happen with VC.)

    There wasn't much done to the library recently, and others on SO have found the trunk lacking in some regards, but in a company I used to work for we have found the guy quite responsive, and one of my then cow-workers even got commit access and added some code to it, so you might find it worth a shot.

    To enumerate your requirements:

    performance

    Best I've found. Especially its ability to exclude log messages at compile-time and have the compiler completely eliminate those was very appealing.

    ease of use (allow streaming or formating or something like that)

    There's the classical horrible compiler error messages of templates-meta stuff when you do something wrong, but when it comes to ease of use, this

    TEMPLOG_LOG(my_logger,sev_error,aud_support) << "logged in as " << user_name;
    

    is hard to beat.
    However, you might have to create your own log sinks (that's where the log messages go), as the few pre-packaged ones (stderr, file, Windows logging, etc.) aren't all that sophisticated. Due to performance being a main goal, the intrinsics of the whole thing are somewhat complicated (like log message formatters being quite tangled with log sinks), but we did master that (I remember stepping through it in a debugger helping with that) and once understood it wasn't all that hard to write your own message formatters or log sinks.

    reliable (don't leak or crash!)

    We have used it without finding any such severe issues. There's virtually no dynamic memory allocation in there, so it's hard to even imagine it doing something wrong. Of course, we only ever put it to real-world tests in one product.

    cross-platform (at least Windows, MacOSX, Linux/Ubuntu)

    When we used it, we used it on Win32, OSX, and several different Linux distributions, Ubuntu among them.

    As for multi-threading: We haven't used this, but from what I remember of the lib's architecture it seems you would only need to handle this in log sinks. ICBWT.

  • log using socket (any socket wrapper can suffice) + web browser websocket => most versatile, unobtrusive logging tool possible, will gain hours of debugging and avoid eye-sore.

    • asyncrhonous (speed as it defers all the job on the browser)
    • formatted (color, size etc..)
    • reliable (sockets...)
    • cross-platform (browser)

    Now, the bonus:

    • dynamic filtering very easily done (using javascript regex if needed)
    • with log history, memory and compare (HTML5 spec on the "in-browser" database)
    • Easy way to make some graph of any data (using SVG, or canvas or anything) like memory, memory fragmentation, etc...
    • easy way to make some 2D graph of any data (kd-tree subdivision ? potential field ? or even just a variable value variation ? etc...)
    • allows distant logging (using the browser other computer)
    • using html5 in browser storage, you can store log session parameteres (current log filters, etc.. and even notes on each)
    • very easy to create bug report or link trac tickets just with a click
    • ability to rewind logging easily, with a timeline gui

    and many more task outside of logging:

    • allows profiler info (graphs...)
    • can even serve as console (send command from browser) or even with quick GUI using some HTML or even flash ui
    • image diff in the browser (send image using socket, and compare in browser using canvas image pixel capabilities)
    • etc...

    (nearly all of the above can be done using flash sockets, save the database capabilities)

    Now I know it seems a bit long to set up the thing. But it really is a gain of time on long project, with hard debugging situation (such as in games.) It's the most powerful thing I used since debuggers...

    Note 1: the only downside => double-check side effect when debugging game networking code (impact on socket buffer size, latency, bandwidth, etc...)

    Note 2: some broswer deactivated by default websocket due to security reason, check about:config things to be sure it's enabled.

Tags
c++ software-engineering performance
Related questions and answers
  • I have a simple question. For people that know and built ogre3D from source as a Static library, what is the order of which the libraries should be linked? The libraries I need to be organized are: Ogre Plugins 'libOgreMain.a' Ogre RenderSystems Boost(version 1.47)link Ogre's Dependencies The reason I'm asking is because in the Ogre forums, I have asked about this and didn't get a good reply... yet. The other reason is because even though I link to the boost library, I get this error: undefined reference to '_imp___ZN5boost6thread20hardware_concurrencyEv' My compiler is MinGW

  • don't need 3D, and it is quite ...a lot of work to learn. I also don't like that it is so expensive to use for different platforms and that I can only code for it through scripting. You have to buy each... c++, I know that there might be some wrappers available, but I don't like to use wrappers, because... Irrlicht. A lot of features, but support seems to be low and it is aimed at enthusiasts. C... of small games but I'm doubtful of the performance. I would like to make a fairly large strategy game, with several hundred units fighting simultaneously, explosions and animations included. Also

  • innefficient. con. Subsystems know about Components. 2: Each Subsystem searches for Components of specific types. pro. Better performance than in Approach 1. con. Subsystems still know about Components. 3: Component registers itself in GameSubsystem(s). We know at compile-time that there is a GameSubsystemRenderer, so let's ComponentImageRender will call something like... GameSubsystems) can implement registerComponent(Component*). pro. Components and GameSubystems know nothing about each other. con. In C++ it would look like ugly and slow typeid-switch

  • animation I would end up storing a lot of data that I don't really need, even if I'm indexing node and frame data when saving and then store the hierarchy with the indices to the actual data. I don't know if my speculations are ok, as I don't have much experience with 3d animations yet. I want to make a well decision as any option I choose would require a lot of work to get it to render and I don't want to find out in the end that I have to rewrite everything again, as a lot of other objects will be working with these data. Sorry if it's a too subjective matter, but I need some insight. I'm

  • that. All this seems well and good, except I have one question, why not linked lists rather than arrays? Sure, if you had to make your own linked list class, I would be on board, but in c++ anyway, assuming... around and found this, which claimed that a lot of older developers didn't want to use STL because it wasn't mature enough. Also, older games AFAIK, used C rather than C++, which also doesn't have STL. And I could see a case there for using arrays rather than linked lists, because you would have to make your own (which while simple enough to do, could potentially lead to many more errors). I also

  • Sorry for the ackward title, but i don't know what to call it exactly. I'm looking for code or libraries that allow easy creation of commonly used user input devices, and code/libs that make gaming controls easy to set up (i'm using SFML and Box2D at the moment) I don't want to re-invent things like buttons, arrows being placed wherever the mouse is located, and more game specific items... or resources out there that i can use to avoid spending much of my time coding these now standard input devices/tecniques?

  • not be running other programs to share the CRT. I don't think I have seen a game needing to upgrade its CRT in its life-cycle. So, why don't games statically link their CRT so they can reduce the extra step...Almost all big titles that I have played require you to install the MSVC runtime. There have been numerous questions about "statically vs. dynamically linked CRT" on StackOverflow, the reasons for dynamic CRT generally boil down to: Reduced memory usage if other programs are using the same libs Can update the libraries independently. But I wonder, how often are these reasons related to game

  • with the Physics correctly... So my main question is: What would be a good combination of libraries to make an online game with? Im sure that many people have good combinations of libraries for making a game... better. I would also like compatability, If Theres one that fits DirectX(at least 9) and OpenGL, then that would be good) 2D Graphics(I liked SFML, so it its possible to get something that works with SFML...) Also if there are any other libraries that work well with these I would like to know. Any answers would be very helpful. and details would be even nicer =) Thanks in advance. -Molma

  • I'm looking into building a cross-platform opensource 2D RPG style game engine for ChaiScript. I want to be able to do all of the graphics with SVG and need joystick input. I also need the libraries I use to be opensource and compatible with the BSD license. I'm familiar with allegro, ClanLib, and SDL. As far as I can tell, none of these libraries have built in or obvious integration for SVG... not seem to have joystick input support, which would require that SDL or some other library also be used. So my question can be summed up as this: What is the best way to get SVG and joystick

Data information