JeGX HackLAB


[English]Small Log System[/English][French]Petit Système de Log[/French]

with one comment




[English]
Here is a small piece of code that can be useful if you need to quickly generate traces (or log) in your apps:
[/English]

[French]
Voilà un petit bout de code qui peut être utile si vous avez besoin de générer rapidement des traces (ou log) dans vos applications:
[/French]

class cLog
{
public:
  cLog(char *logfile){};
  static void trace(const char *s)
  { if(s) log <<  s << std::endl; };
  static std::ofstream log;
};
std::ofstream cLog::log("c:\\app_log.txt");

[English]
Just use it as follows:
[/English]

[French]
Il suffit de l’utiliser de la manière suivante:
[/French]

cLog::trace("this is a log");
cLog::trace("this is a second trace");









358 views

Written by JeGX

May 27th, 2008 at 4:08 pm

Posted in Programming

Tagged with , , ,

One Response to '[English]Small Log System[/English][French]Petit Système de Log[/French]'

Subscribe to comments with RSS or TrackBack to '[English]Small Log System[/English][French]Petit Système de Log[/French]'.

  1. we should put std::ofstream cLog::log(“xxx”) to cpp file, not the header file.

    carl

    10 Dec 09 at 8:38 am

Leave a Reply