Sign in to follow this  
Peter_APIIT

C++ Logger Tutorial

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this