ChessUSA.com TalkChess.com
Hosted by Your Move Chess & Games
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A logging facility
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions Flat
View previous topic :: View next topic  
Author Message
Vincent Diepeveen



Joined: 09 Mar 2006
Posts: 1738
Location: The Netherlands

PostPost subject: Re: A logging facility    Posted: Mon Mar 19, 2012 7:37 am Reply to topic Reply with quote

mcostalba wrote:
bob wrote:
I even wrote a Print() function


The point is doing it _without_ writing a custom Print() function or whatever else. And without changing any existing line and with zero overhead (your Print() function is something added above the standard functions). Please don't take it personally, but I think you have not understood the topic, but believe me it is a very interesting piece of code otherwise I would had not dedicated a specific post here.


From the added code:

Code:
 
+/// Our fancy logging facility. The trick here is to replace cout.rdbuf() with

     110    

+/// this one that sends the output both to console and to a file, this allow us

     111    

+/// to toggle the logging of std::cout to a file while preserving output to

     112    

+/// stdout and without changing a single line of code! Idea and code from:

     113    

+/// http://groups.google.com/group/comp.lang.c++/msg/1d941c0f26ea0d81


In C++ equivalents that's the same thing as Bob's Print command in C is. No matter how you define things, *somewhere* you do the exact same thing, and as USUAL, in c++ you needed to add more lines of code than Bob has in his Print function in C.

Diep had this by the way since mid 90s as well, and of course as it's C it's not so easy to use function overloading (or whatever name you want to give it) but i also call a function. Not the overloaded cout.rdbuf function, and in the background of course there runs then 'if then else' code generated by the compiler to choose which function to use, but in C of course it's a tad smaller than Bob's Print function, yet similar.

Yet i'm not doing as if there is nowhere in the code a compiler generated 'if then else' at the end that's basically the same.

BECAUSE you have an object oriented programming language, you shouldn't do as if you invent something new, as you didn't.

Thanks,
Vincent
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Subject Author Date/Time
A logging facility Marco Costalba Sun Mar 18, 2012 10:23 pm
      Re: A logging facility Gary Sun Mar 18, 2012 11:56 pm
      Re: A logging facility Robert Hyatt Mon Mar 19, 2012 3:50 am
            Re: A logging facility Marco Costalba Mon Mar 19, 2012 7:18 am
                  Re: A logging facility Vincent Diepeveen Mon Mar 19, 2012 7:37 am
                        Re: A logging facility Marco Costalba Mon Mar 19, 2012 7:50 am
                              Re: A logging facility Vincent Diepeveen Mon Mar 19, 2012 8:22 am
                                    Re: A logging facility Jan Brouwer Mon Mar 19, 2012 6:43 pm
                                          Re: A logging facility Robert Hyatt Mon Mar 19, 2012 6:54 pm
                                                Re: A logging facility Jan Brouwer Mon Mar 19, 2012 8:00 pm
                                                      Re: A logging facility Marco Costalba Mon Mar 19, 2012 9:09 pm
                                                            Re: A logging facility Daniel Shawul Mon Mar 19, 2012 9:37 pm
                                                            Re: A logging facility Marco Costalba Tue Mar 20, 2012 8:30 pm
                                                Re: A logging facility Ben-Hur Carlos Langoni Wed Mar 21, 2012 2:16 am
                                                      Re: A logging facility Daniel Shawul Wed Mar 21, 2012 9:20 am
                                                            Re: A logging facility Ben-Hur Carlos Langoni Wed Mar 21, 2012 1:54 pm
                                                                  Re: A logging facility Daniel Shawul Wed Mar 21, 2012 3:38 pm
                                                            Re: A logging facility Marco Costalba Thu Mar 22, 2012 8:01 pm
                                                                  Re: A logging facility Daniel Shawul Thu Mar 22, 2012 10:48 pm
                                                                        Re: A logging facility Rein Halbersma Fri Mar 23, 2012 7:03 am
                                                                              Re: A logging facility Daniel Shawul Fri Mar 23, 2012 10:04 am
                                                                                    Re: A logging facility Rein Halbersma Fri Mar 23, 2012 12:32 pm
                                                                                          Re: A logging facility Martin Sedlak Fri Mar 23, 2012 1:00 pm
                                                                                          Re: A logging facility Daniel Shawul Fri Mar 23, 2012 2:05 pm
                                                      Re: A logging facility Robert Hyatt Wed Mar 21, 2012 4:36 pm
                                                      Re: A logging facility Mark Pearce Wed Mar 28, 2012 12:49 pm
                  Re: A logging facility Rein Halbersma Mon Mar 19, 2012 7:50 am
                        Re: A logging facility Marco Costalba Mon Mar 19, 2012 8:00 am
                              Re: A logging facility Rein Halbersma Mon Mar 19, 2012 8:09 am
                        Re: A logging facility Robert Hyatt Mon Mar 19, 2012 6:56 pm
      Re: A logging facility Daniel Shawul Mon Mar 19, 2012 7:52 pm
            Re: A logging facility Robert Hyatt Wed Mar 21, 2012 1:26 am
                  Re: A logging facility Daniel Shawul Wed Mar 21, 2012 9:00 am
      Re: A logging facility H.G.Muller Wed Mar 21, 2012 7:58 am
            Re: A logging facility Vincent Diepeveen Wed Mar 21, 2012 2:39 pm
                  Re: A logging facility H.G.Muller Wed Mar 21, 2012 5:29 pm
            Re: A logging facility H.G.Muller Thu Mar 22, 2012 8:11 am
                  Re: A logging facility Daniel Shawul Thu Mar 22, 2012 11:18 pm
Post new topic    TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
Enhanced with Moby Threads