Subversion Repositories tpanel

Rev

Rev 385 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 385 Rev 386
Line 25... Line 25...
25
//#ifdef __APPLE__
25
//#ifdef __APPLE__
26
//#include <unistd.h>
26
//#include <unistd.h>
27
//#include <sys/syscall.h>
27
//#include <sys/syscall.h>
28
//#endif
28
//#endif
29
 
29
 
-
 
30
#include <QMessageBox>
-
 
31
#include <QTimer>
-
 
32
 
30
#include "terror.h"
33
#include "terror.h"
31
#include "tconfig.h"
34
#include "tconfig.h"
32
 
35
 
33
#include <QMessageBox>
-
 
34
#include <QTimer>
-
 
35
 
36
 
36
#if LOGPATH == LPATH_SYSLOG || defined(__ANDROID__)
37
#if LOGPATH == LPATH_SYSLOG || defined(__ANDROID__)
37
#   ifdef __ANDROID__
38
#   ifdef __ANDROID__
38
#       include <android/log.h>
39
#       include <android/log.h>
39
#   else
40
#   else
40
#       include <syslog.h>
41
#       include <syslog.h>
-
 
42
#       ifdef __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
-
 
43
#           include "ios/QASettings.h"
-
 
44
#       endif
41
#   endif
45
#   endif
42
#endif
46
#endif
43
 
47
 
44
#define LOGBUFFER_SIZE      4096
48
#define LOGBUFFER_SIZE      4096
45
 
49
 
Line 143... Line 147...
143
                    case TERRNONE:      eType = ANDROID_LOG_INFO; break;
147
                    case TERRNONE:      eType = ANDROID_LOG_INFO; break;
144
                }
148
                }
145
 
149
 
146
                rc = __android_log_print(eType, "tpanel", "%s", writebuf) > 0;
150
                rc = __android_log_print(eType, "tpanel", "%s", writebuf) > 0;
147
#else
151
#else
-
 
152
#ifdef Q_OS_IOS
-
 
153
                QASettings::writeLog(TError::getErrorType(), writebuf);
-
 
154
#else
148
                switch(TError::getErrorType())
155
                switch(TError::getErrorType())
149
                {
156
                {
150
                    case TERRINFO:      eType = LOG_INFO; break;
157
                    case TERRINFO:      eType = LOG_INFO; break;
151
                    case TERRWARNING:   eType = LOG_WARN; break;
158
                    case TERRWARNING:   eType = LOG_WARNING; break;
152
                    case TERRERROR:     eType = LOG_ERROR; break;
159
                    case TERRERROR:     eType = LOG_ERR; break;
153
                    case TERRTRACE:     eType = LOG_INFO; break;
160
                    case TERRTRACE:     eType = LOG_INFO; break;
154
                    case TERRDEBUG:     eType = LOG_DEBUG; break;
161
                    case TERRDEBUG:     eType = LOG_DEBUG; break;
155
                    case TERRNONE:      eType = LOG_INFO; break;
162
                    case TERRNONE:      eType = LOG_INFO; break;
156
                }
163
                }
157
 
164
 
158
                syslog(eType, writebuf);
165
                syslog(eType, "(tpanel) %s", writebuf);
159
                rc = 1;
166
                rc = 1;
160
#endif
167
#endif  // Q_OS_IOS
-
 
168
#endif  // __ANDROID__
161
                this->setp(buffer, buffer + bufsize - 1);
169
                this->setp(buffer, buffer + bufsize - 1);
162
            }
170
            }
163
 
171
 
164
            return rc;
172
            return rc;
165
        }
173
        }
Line 630... Line 638...
630
        mFile = mFile.substr(pos + 1);
638
        mFile = mFile.substr(pos + 1);
631
 
639
 
632
    TError::setErrorType(TERRTRACE);
640
    TError::setErrorType(TERRTRACE);
633
    std::lock_guard<mutex> guardm(message_mutex);
641
    std::lock_guard<mutex> guardm(message_mutex);
634
 
642
 
635
#if LOGPATH == LPATH_FILE
-
 
636
    if (!TConfig::isLongFormat())
643
    if (!TConfig::isLongFormat())
637
        *TError::Current()->getStream() << "TRC " << std::setw(5) << std::right << line << ", " << _threadIDtoStr(mThreadID) << " " << indent << "{entry " << msg << std::endl;
644
        *TError::Current()->getStream() << "TRC " << std::setw(5) << std::right << line << ", " << _threadIDtoStr(mThreadID) << " " << indent << "{entry " << msg << std::endl;
638
    else
645
    else
639
        *TError::Current()->getStream() << TStreamError::getTime() <<  " TRC " << std::setw(5) << std::right << line << ", " << std::setw(20) << std::left << mFile << ", " << _threadIDtoStr(mThreadID) << " " << indent << "{entry " << msg << std::endl;
646
        *TError::Current()->getStream() << TStreamError::getTime() <<  " TRC " << std::setw(5) << std::right << line << ", " << std::setw(20) << std::left << mFile << ", " << _threadIDtoStr(mThreadID) << " " << indent << "{entry " << msg << std::endl;
640
#else
-
 
641
    std::stringstream s;
-
 
642
 
647
 
643
    if (!TConfig::isLongFormat())
-
 
644
        s  << "TRC " << std::setw(5) << std::right << line << ", " << &indents << "{entry " << msg << std::endl;
-
 
645
    else
-
 
646
        s << TStreamError::getTime() <<  " TRC " << std::setw(5) << std::right << line << ", " << std::setw(20) << std::left << mFile << ", " << _threadIDtoStr(mThreadID) << &indents << "{entry " << msg << std::endl;
-
 
647
 
-
 
648
    TError::Current()->logMsg(s);
-
 
649
#endif
-
 
650
    TError::Current()->incIndent();
648
    TError::Current()->incIndent();
651
    mHeadMsg = msg;
649
    mHeadMsg = msg;
652
    mLine = line;
650
    mLine = line;
653
 
651
 
654
    if (TConfig::getProfiling())
652
    if (TConfig::getProfiling())
Line 675... Line 673...
675
        s << std::chrono::duration_cast<std::chrono::nanoseconds> (difftime).count() << "[ns]" << " --> " << std::chrono::duration_cast<std::chrono::seconds>(secs).count() << "s " << std::chrono::duration_cast<std::chrono::milliseconds>(msecs).count() << "ms";
673
        s << std::chrono::duration_cast<std::chrono::nanoseconds> (difftime).count() << "[ns]" << " --> " << std::chrono::duration_cast<std::chrono::seconds>(secs).count() << "s " << std::chrono::duration_cast<std::chrono::milliseconds>(msecs).count() << "ms";
676
        nanosecs = s.str();
674
        nanosecs = s.str();
677
    }
675
    }
678
 
676
 
679
    std::lock_guard<mutex> guardm(message_mutex);
677
    std::lock_guard<mutex> guardm(message_mutex);
680
#if LOGPATH == LPATH_FILE
-
 
-
 
678
 
681
    if (TConfig::getProfiling())
679
    if (TConfig::getProfiling())
682
    {
680
    {
683
        if (!TConfig::isLongFormat())
681
        if (!TConfig::isLongFormat())
684
            *TError::Current()->getStream() << "TRC      , " << _threadIDtoStr(mThreadID) << " " << indent << "}exit " << mHeadMsg << " Elapsed time: " << nanosecs << std::endl;
682
            *TError::Current()->getStream() << "TRC      , " << _threadIDtoStr(mThreadID) << " " << indent << "}exit " << mHeadMsg << " Elapsed time: " << nanosecs << std::endl;
685
        else
683
        else
Line 690... Line 688...
690
        if (!TConfig::isLongFormat())
688
        if (!TConfig::isLongFormat())
691
            *TError::Current()->getStream() << "TRC      , " << _threadIDtoStr(mThreadID) << " " << indent << "}exit " << mHeadMsg << std::endl;
689
            *TError::Current()->getStream() << "TRC      , " << _threadIDtoStr(mThreadID) << " " << indent << "}exit " << mHeadMsg << std::endl;
692
        else
690
        else
693
            *TError::Current()->getStream() << TStreamError::getTime() << " TRC      , " << std::setw(20) << std::left << mFile << ", " << _threadIDtoStr(mThreadID) << " " << indent << "}exit " << mHeadMsg << std::endl;
691
            *TError::Current()->getStream() << TStreamError::getTime() << " TRC      , " << std::setw(20) << std::left << mFile << ", " << _threadIDtoStr(mThreadID) << " " << indent << "}exit " << mHeadMsg << std::endl;
694
    }
692
    }
695
#else
-
 
696
    std::stringstream s;
-
 
697
 
693
 
698
    if (!TConfig::isLongFormat())
-
 
699
        s << "TRC      , " << &indents << "}exit " << mHeadMsg;
-
 
700
    else
-
 
701
        s << TStreamError::getTime() << " TRC      , " << std::setw(20) << std::left << mFile << ", " << _threadIDtoStr(mThreadID) << " " << &indents << "}exit " << mHeadMsg;
-
 
702
 
-
 
703
    if (TConfig::getProfiling())
-
 
704
        s  << " Elapsed time: " << nanosecs << std::endl;
-
 
705
    else
-
 
706
        s << std::endl;
-
 
707
 
-
 
708
    TError::Current()->logMsg(s);
-
 
709
#endif
-
 
710
    mHeadMsg.clear();
694
    mHeadMsg.clear();
711
}
695
}
712
 
696
 
713
/********************************************************************/
697
/********************************************************************/
714
 
698