123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #ifndef LIGHTLOG_H
- #define LIGHTLOG_H
- #include <QDebug>
- #include <QDateTime>
- // #define LOG_DEBUG(msg) do{ QString file = __FILE__; qDebug("[%s] [ %s:%d ] %s", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str() , file.right(file.count() - file.lastIndexOf('/') -1).toStdString().c_str() , __LINE__ , msg); }while(0)
- // #define LOG_INFO(msg) do{ QString file = __FILE__; qInfo("[%s] [ %s:%d ] %s", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str() , file.right(file.count() - file.lastIndexOf('/') -1).toStdString().c_str() , __LINE__ , msg); }while(0)
- // #define LOG_WARN(msg) do{ QString file = __FILE__; qWarning("[%s] [ %s:%d ] %s", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str() , file.right(file.count() - file.lastIndexOf('/') -1).toStdString().c_str() , __LINE__ , msg); }while(0)
- // #define LOG_DEBUG(_log_msg) do{ QString _log_file = __FILE__; QString _log_str = '[' + QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") + ']' + '[' + _log_file.right(file.count() - _log_file.lastIndexOf('/') -1) + ':' + QString::number(__LINE__) + "] " + _log_msg; qDebug() << _log_str; }while(0)
- // #define LOG_INFO(_log_msg) do{ QString _log_file = __FILE__; QString _log_str = '[' + QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") + ']' + '[' + _log_file.right(file.count() - _log_file.lastIndexOf('/') -1) + ':' + QString::number(__LINE__) + "] " + _log_msg; qInfo() << _log_str; }while(0)
- // #define LOG_WARN(_log_msg) do{ QString _log_file = __FILE__; QString _log_str = '[' + QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") + ']' + '[' + _log_file.right(file.count() - _log_file.lastIndexOf('/') -1) + ':' + QString::number(__LINE__) + "] " + _log_msg; qWarning() << _log_str; }while(0)
- /********** LOG_DEBUG **********/
- #define QLOG_DEBUG(_log_msg) \
- do { \
- QString _log_file = __FILE__; \
- QString _log_str = '[' + \
- QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") \
- + ']' + '[' + \
- _log_file.right(_log_file.count() - _log_file.lastIndexOf('/') -1) \
- + ':' + \
- QString::number(__LINE__) + "] " + _log_msg; \
- qDebug() << _log_str; \
- } while(0)
- /********** LOG_INFO **********/
- #define QLOG_INFO(_log_msg) \
- do { \
- QString _log_file = __FILE__; \
- QString _log_str = \
- '[' + \
- QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") + \
- ']' + '[' + \
- _log_file.right(_log_file.count() - _log_file.lastIndexOf('/') - 1) \
- + ':' + \
- QString::number(__LINE__) + "] " + _log_msg; \
- qInfo() << _log_str; \
- } while (0)
- /********** LOG_WARN **********/
- #define QLOG_WARN(_log_msg) \
- do { \
- QString _log_file = __FILE__; \
- QString _log_str = \
- '[' + \
- QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz") + \
- ']' + '[' + \
- _log_file.right(_log_file.count() - _log_file.lastIndexOf('/') - 1) \
- + ':' + \
- QString::number(__LINE__) + "] " + _log_msg; \
- qWarning() << _log_str; \
- } while (0)
- // void hello()
- // {
- // QString file = __FILE__;
- // file.lastIndexOf('/');
- // file.right(file.count() - file.lastIndexOf('/')).toStdString().c_str();
- // QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz");
- // qInfo("[%s] [ %s:%d ] %s", QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.zzz").toStdString().c_str() , file.right(file.count() - file.lastIndexOf('/') -1).toStdString().c_str() , __LINE__ , "hello");
-
- // }
- #endif /* LIGHTLOG_H */
|