C++ Logger Tutorial

Started by
6 comments, last by Peter_APIIT 14 years, 8 months ago
Hello to all, i am a student and i would like to develop a simple C++ logger for my project. I have did quite amount of research including link listed below but i could not understand how it works.
Quote: http://www.gamedev.net/reference/snippets/features/stlLogSnippet/ http://www.codeproject.com/KB/cpp/CPP_logging.aspx http://www.velocityreviews.com/forums/t288879-efficient-logging-in-c.html http://software.intel.com/en-us/articles/building-of-systems-of-automatic-cc-code-logging/ http://developers.sun.com/solaris/articles/logging.html http://www.karlockhart.com/wordpress/2009/01/04/very-basic-logging-for-c/ http://www.serverwatch.com/tutorials/article.php/1129851 http://www.serverwatch.com/tutorials/article.php/3376671 http://docs.hp.com/en/B9901-90031/ch04s05.html http://www.loganalysis.org/ http://www.torjo.com/code/logging-v131.zips
Question: 1. What is the usage/function/purposes of ifdef DEBUG and compare to class? 2. What function should a logger have ? Logger Requirement: 1. Develop in C++ template or class 2. Portable approach like Consider logging to std::clog. You can replace the clog streambuf with the streambuf of your choice (to a file, socket, window, stdout, stdcerr whatever). Example code is welcome. Thanks for any advice.
Advertisement
Those questions and requirements sound like they were taken directly off your class assignment.


Go back and read those articles you listed.



The two questions are answered directly in a few of those articles.

Several of those articles have complete code listings for logging classes that satisfy your requirements and more. It should be more than enough to cover everything you need to know for your course.


If you have other specific questions (rather than asking us to do your homework), please feel free to ask those.
If you prefer books Ron Penton's "Mud Game Programming" book walks you through the whole process(see p. 122) although it might be hard to find a copy since even used copies are going for $80!
[size="2"]Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe
Quote:Original post by Peter_APIIT
Question:
1. What is the usage/function/purposes of ifdef DEBUG and compare to class?

This doesn't really make sense.

Quote:
2. What function should a logger have ?

It's your logger. You know best.


Quote:
Logger Requirement:
1. Develop in C++ template or class
2. Portable approach like Consider logging to std::clog. You can replace the clog streambuf
with the streambuf of your choice (to a file, socket, window, stdout, stdcerr
whatever).

Example code is welcome.

Thanks for any advice.

In the other thread you started with exactly the same title, you were given links to example code, techniques and tutorials. Were they not sufficient?
This is not a homework. I code it during my spare time.

I would like to understand these issues first before i start implement it.

Thanks for your help.
Loggers with a bunch of features are often unnecessary for most hobby game projects. If you really are writing a logger for one of your own projects, what features do you really need?

If you just need to log simple messages to a file, why not just use std::ofstream?
I've got a logging tutorial on my website.
Yes, i willing to use ofstream but i need to clear the myth.

Does logger logging another program at run time ?

How to achieve that ?

Thanks.

This topic is closed to new replies.

Advertisement