CFanatic

Go Back   CFanatic > Programming > C++ Programming

Join CFanatic Forum Now

Logger Class in C++ topic posted under C++ Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 06-28-2010, 08:16 AM
Junior Member
 
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
senseiwa is on a distinguished road
| More
Logger Class in C++

Hi! I am trying to implement a logger class that behaves like printf: this is the only requirement, to implement a member function that accepts a format and a variable number of arguments, just like printf.

However, the static member Logger::log is implemented using old-style C streams:


Code:
void Logger::log(char *format, ...)
{

#ifdef DEBUG
    va_list args;
    char    *p;
    
    // Check for null argument list
    va_start(args, format);    
    p = va_arg(args, char*);

    va_end(args);
    
        //
    va_start(args, format);
    if (p == NULL)
    {

        fprintf(logger, "%s", format);
    }
    else
    {
        fvprintf(logger, format, args);

    }
    
    va_end(args);
#endif
}
My question is simple. Is there a way of moving away the FILE* logger, replacing it with some C++ iostream-reletated class?

Sorry for this (probably) simple question!


Thanks and Cheers!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pointer and Class inspiration C++ Programming 8 05-31-2010 08:55 PM
Single ton class operator creative C++ Programming 13 05-30-2010 09:46 PM
get Class johny10151981 Win32 Programming 1 10-07-2008 03:58 AM
sizeof for a class coderzone C Programming 2 06-05-2007 10:29 PM
Class Project aaholland C++ Programming 0 09-11-2006 11:40 PM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 04:18 AM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board