Jump to content
  • Advertisement
Sign in to follow this  
cozzie

Creating of logging system

This topic is 761 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

During the journey called my new (d3d11) engine, I've encountered (and got feedback) on the usage of OutputDebugString.

I personally find it very handy during debugging, because I can see results right away.

 

But in release mode this won't bring anything.

So now I'm thinking about creating a logging system.

Basically a class which allows me to simply report text/ errors/ info etc. to a ASCII file (with a header that I'll include where needed).

I'm not sure yet how that would work with opening a filestream and when to close it, because calling the logging system would be from anywhere/ many different places (no in scope object everywhere).

 

With this I'm thinking of also adding the lines to the debugger output (OutputDebugString), so I have the best of both worlds.

Do you have any advice on this, or maybe best practices?

Share this post


Link to post
Share on other sites
Advertisement

Yep, the logging issue has really been solved in most languages and better to make use of those than re-invent :)

Share this post


Link to post
Share on other sites

I have build up a logging system for my engine framework too that is realy simple and leight weight. The main part was to make it multi-threaded by adding an internal queue for each of a number of previously set threads. Simple spin-lock lets threads add messages and and keeps the internal running publishing thread up from outputting waste.

 

This I have added a handler interface so that you were able to change the output method like to file or remote via UDP socket.

At least added a template function so that I'm possible to call something similar to C#'s string.Format when writing log messages. I think it is more simple than printf but thats a taste thing.

 

I have had doing this in less than 8 hours so it should also be very simple for you to do something similar if you decide to

Share this post


Link to post
Share on other sites
Thanks all.
I really like the simplicity of easylogging++ and will probably go for that one.

From a practical point of view, how do you quickly check the results in the output file when debugging? From that standpoint the VS debugger output directly stands out and is always visible. Are there any tricks, for example to show the logfile in a browser or other application that constantly refreshes?

Share this post


Link to post
Share on other sites

From a practical point of view, how do you quickly check the results in the output file when debugging? From that standpoint the VS debugger output directly stands out and is always visible. Are there any tricks, for example to show the logfile in a browser or other application that constantly refreshes?

VS will ask you if you want to reload a file whenever it's externally modified. However, your logger should have an option to write to a file and to whatever the native console/TTL output is, such as DebugOutputString, or even stdout. Other platforms will have their own equivalents to DebugOutputString, which may, for example, automatically send the data from a console devkit over a network to a system tray app on your dev PC.

Share this post


Link to post
Share on other sites

Thanks.

@Hodgman: sounds fancy, not sure if Easylogging++ supports that.

But ideally I want a lightweight solution which can output to 2 paths: a text file + debugger output (OutputDebugString).

If if only supports the 1st one, I can search for a simple tail program (like the suggested mTail).

Share this post


Link to post
Share on other sites

I've got Easlyogging++ up and running, works like a charm (lightweight and easy to use without lib's, just 1 include).

What I do encounter is a decision I have to make in the workflow:

 

- the logger outputs logging in a file, which can be read (and perhaps tailed in a tool like mTail)

- Visual Studio debugger output shows D3D info/warning/logging, VLD (visual leak detector) and other API feedback

 

How do you handle this situation in practice?

Do you keep an eye out on both 'streams',  or do you combine logging information for API's and your own framework?

 

My current view on this, is that it could work fine besides each other, because when something fails/ unexpected happens, you just have 2 sources to look for information. I personally think combining both will not bring enough, looking at the needed effort. The Easylogging++ API doesn't support outputting to the VS debugger output, unless I redirect stdout (which it does output) to the VS output debugger. Googling doesn't leed me to an easy solution of doing this.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!