I wrote a qt small console utility for testing database connectivity, the code block is:
db.setHostName("hostIP");
db.setDatabaseName("name");
db.setUserName("uid");
db.setPassword("pw");
db.setPort(1521);
while(true)
{
if (db.open())
{
qDebug()<<"OPEN";
db.close();
}
else
{
qDebug()<<"YOU MESSED UP "<<db.lastError().text();
}
}
the console output when the database is down or cannot be connected can be seen in the console output, what I want is to tee the timestamp also.
Is there a way to print the event timestamp on the console along with the qDebug messages ???
Sure you can. For doing so you can use QTime class, i.e.:
qDebug() << QTime::currentTime().toString() << "YOU MESSED UP "<< db.lastError().text();
Or, in the same way you can print out the date and time information with using QDateTime::currentDateTime()
function.