D
Dennis Lubert
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi people,
I want to create my own variant of a cout Object, so that I can use
different of those for debugging...
Like this class, but as a stream...
class Log
{
private:
static int system_debuglevel;
int debuglevel;
public:
Log( int dl ) : debuglevel(dl) { }
void logthis( const char * msg)
{
if ( debuglevel <= system_debuglevel ) printf("%s", msg);
}
}
So that I can create global objects like those :
Debug(5);
Info(4);
Warn(3);
Error(2);
and can then do Debug << "DEBUGMESSAGE" << endl; with every kind of
object that has a ostream& operator<<()..
So I could need some help with this, I have tried to derive the
logger from ostream, I have tried template functions, but nothing
works really good... the class should then do the output decision for
Debug << "String" << 5 << 4.5f << endl; correctly, but it always
outputs only String, or always 5 and 4.5 regardless whaat
system_debuglevel is set... I could need some help...
greets
Dennis
-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.1
iQA/AwUBP4VyFhL69PVFlLwmEQLhswCgtBt1938ibhAXIKdiRjEDan1AYwsAn0Nq
UUT+Cq0VLMAq9pRd9twbtN0C
=fsht
-----END PGP SIGNATURE-----
Hash: SHA1
Hi people,
I want to create my own variant of a cout Object, so that I can use
different of those for debugging...
Like this class, but as a stream...
class Log
{
private:
static int system_debuglevel;
int debuglevel;
public:
Log( int dl ) : debuglevel(dl) { }
void logthis( const char * msg)
{
if ( debuglevel <= system_debuglevel ) printf("%s", msg);
}
}
So that I can create global objects like those :
Debug(5);
Info(4);
Warn(3);
Error(2);
and can then do Debug << "DEBUGMESSAGE" << endl; with every kind of
object that has a ostream& operator<<()..
So I could need some help with this, I have tried to derive the
logger from ostream, I have tried template functions, but nothing
works really good... the class should then do the output decision for
Debug << "String" << 5 << 4.5f << endl; correctly, but it always
outputs only String, or always 5 and 4.5 regardless whaat
system_debuglevel is set... I could need some help...
greets
Dennis
-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.1
iQA/AwUBP4VyFhL69PVFlLwmEQLhswCgtBt1938ibhAXIKdiRjEDan1AYwsAn0Nq
UUT+Cq0VLMAq9pRd9twbtN0C
=fsht
-----END PGP SIGNATURE-----