![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Console. More...
#include <ecvConsole.h>


Public Slots | |
| void | refresh () |
| Refreshes console (display all messages still in queue) More... | |
Public Member Functions | |
| ~ecvConsole () override | |
| Destructor. More... | |
| void | setAutoRefresh (bool state) |
| Sets auto-refresh state. More... | |
| bool | setLogFile (const QString &logPrefix) |
| Sets log file with prefix (generates timestamped log file like glog) More... | |
| QWidget * | parentWidget () |
| Returns the parent widget (if any) More... | |
Public Member Functions inherited from CVLog | |
| virtual | ~CVLog () |
| Destructor. More... | |
Static Public Member Functions | |
| static void | Init (QListWidget *textDisplay=nullptr, QWidget *parentWidget=nullptr, MainWindow *parentWindow=nullptr, bool redirectToStdOut=false) |
| Inits console (and optionaly associates it with a text output widget) More... | |
| static ecvConsole * | TheInstance (bool autoInit=true) |
| Returns the (unique) static instance. More... | |
| static void | ReleaseInstance (bool flush=true) |
| Releases unique instance. More... | |
| static void | EnableQtMessages (bool state) |
| Whether to show Qt messages (qDebug / qWarning / etc.) in Console. More... | |
| static bool | QtMessagesEnabled () |
Static Public Member Functions inherited from CVLog | |
| static CVLog * | TheInstance () |
| Returns the static and unique instance. More... | |
| static void | RegisterInstance (CVLog *logInstance) |
| Registers a unique instance. More... | |
| static void | EnableMessageBackup (bool state) |
| Enables the message backup system. More... | |
| static int | VerbosityLevel () |
| Returns the current verbosity level. More... | |
| static void | SetVerbosityLevel (int level) |
| Sets the verbosity level. More... | |
| static void | LogMessage (const QString &message, int level) |
| Static shortcut to CVLog::logMessage. More... | |
| static bool | PrintVerbose (const char *format,...) |
| Prints out a verbose formatted message in console. More... | |
| static bool | PrintVerbose (const QString &message) |
| QString version of ccLog::PrintVerbose. More... | |
| static bool | Print (const char *format,...) |
| Prints out a formatted message in console. More... | |
| static bool | Print (const QString &message) |
| QString version of ccLog::Print. More... | |
| static bool | PrintHigh (const char *format,...) |
| Prints out an important formatted message in console. More... | |
| static bool | PrintHigh (const QString &message) |
| QString version of ccLog::PrintHigh. More... | |
| static bool | PrintDebug (const char *format,...) |
| Same as Print, but works only in Debug mode. More... | |
| static bool | PrintDebug (const QString &message) |
| QString version of ccLog::PrintDebug. More... | |
| static bool | Warning (const char *format,...) |
| Prints out a formatted warning message in console. More... | |
| static bool | Warning (const QString &message) |
| QString version of ccLog::Warning. More... | |
| static bool | WarningDebug (const char *format,...) |
| Same as Warning, but works only in Debug mode. More... | |
| static bool | WarningDebug (const QString &message) |
| QString version of ccLog::WarningDebug. More... | |
| static bool | Error (const char *format,...) |
| Display an error dialog with formatted message. More... | |
| static bool | Error (const QString &message) |
| QString version of 'Error'. More... | |
| static bool | ErrorDebug (const char *format,...) |
| Same as Error, but works only in Debug mode. More... | |
| static bool | ErrorDebug (const QString &message) |
| QString version of ccLog::ErrorDebug. More... | |
Protected Types | |
| using | ConsoleItemType = QPair< QString, int > |
| Queue element type (message + color) More... | |
Protected Member Functions | |
| ecvConsole () | |
| Default constructor. More... | |
| void | logMessage (const QString &message, int level) override |
| Generic message logging method. More... | |
Static Protected Member Functions | |
| static QString | generateLogFileName (const QString &prefix) |
| Generate log file name with timestamp and pid. More... | |
| static QString | getLogDirectory () |
| Get appropriate log directory path (handles permissions on Ubuntu) More... | |
Protected Attributes | |
| QListWidget * | m_textDisplay |
| Associated text display widget. More... | |
| QWidget * | m_parentWidget |
| Parent widget. More... | |
| MainWindow * | m_parentWindow |
| Parent window (if any) More... | |
| QMutex | m_mutex |
| Mutex for concurrent thread access to console. More... | |
| QVector< ConsoleItemType > | m_queue |
| Queue for incoming messages. More... | |
| QTimer | m_timer |
| Timer for auto-refresh. More... | |
| QFile | m_logFile |
| Log file. More... | |
| QTextStream * | m_logStream |
| Log file stream. More... | |
Static Protected Attributes | |
| static bool | s_showQtMessagesInConsole = false |
| Whether to show Qt messages (qDebug / qWarning / etc.) in Console. More... | |
| static bool | s_redirectToStdOut = false |
Additional Inherited Members | |
Public Types inherited from CVLog | |
| enum | MessageLevelFlags { LOG_VERBOSE = 0 , LOG_STANDARD = 1 , LOG_IMPORTANT = 2 , LOG_WARNING = 3 , LOG_ERROR = 4 , DEBUG_FLAG = 8 } |
| Message level. More... | |
Console.
Definition at line 35 of file ecvConsole.h.
|
protected |
Queue element type (message + color)
Definition at line 118 of file ecvConsole.h.
|
override |
|
protected |
Default constructor.
Constructor is protected to avoid using this object as a non static class.
Definition at line 99 of file ecvConsole.cpp.
Referenced by Init(), and TheInstance().
|
static |
Whether to show Qt messages (qDebug / qWarning / etc.) in Console.
Definition at line 170 of file ecvConsole.cpp.
References ecvPS::Console(), s_showQtMessagesInConsole, and ecvSettingManager::setValue().
|
staticprotected |
Generate log file name with timestamp and pid.
Definition at line 345 of file ecvConsole.cpp.
Referenced by setLogFile().
|
staticprotected |
Get appropriate log directory path (handles permissions on Ubuntu)
Definition at line 357 of file ecvConsole.cpp.
References cloudViewer::t::geometry::path.
Referenced by setLogFile().
|
static |
Inits console (and optionaly associates it with a text output widget)
WARNING: in release mode, no message will be output if no 'textDisplay' widget is defined. Moreover, error messages will only appear in a (blocking) QMessageBox if a 'parentWidget' widget is defined. In debug mode, all message are sent to system console (with 'printf').
| textDisplay | text output widget (optional) |
| parentWidget | parent widget (optional) |
| parentWindow | parent window (if any - optional) |
Definition at line 178 of file ecvConsole.cpp.
References ecvPS::Console(), ecvConsole(), ecvSettingManager::getValue(), Settings::LOGFILE_PREFIX, myMessageOutput(), parentWidget(), CVLog::RegisterInstance(), s_console, s_redirectToStdOut, and s_showQtMessagesInConsole.
Referenced by ccCommandLineParser::Parse(), and CommandLogFile::process().
|
overrideprotectedvirtual |
Generic message logging method.
To be implemented by child class.
| message | message |
| level | message severity (see MessageLevelFlags) |
Implements CVLog.
Definition at line 276 of file ecvConsole.cpp.
References DATETIME, QtCompat::endl(), CVLog::LOG_ERROR, CVLog::LOG_VERBOSE, CVLog::LOG_WARNING, m_logFile, m_logStream, m_mutex, m_parentWidget, m_queue, m_textDisplay, and s_redirectToStdOut.
|
inline |
Returns the parent widget (if any)
Definition at line 83 of file ecvConsole.h.
References m_parentWidget.
Referenced by Init().
|
inlinestatic |
Returns whether to show Qt messages (qDebug / qWarning / etc.) in Console or not
Definition at line 80 of file ecvConsole.h.
References s_showQtMessagesInConsole.
Referenced by myMessageOutput().
|
slot |
Refreshes console (display all messages still in queue)
Definition at line 224 of file ecvConsole.cpp.
References ecvColor::blue(), CVLog::DEBUG_FLAG, MainWindow::forceConsoleDisplay(), CVLog::LOG_ERROR, CVLog::LOG_WARNING, m_logFile, m_logStream, m_mutex, m_parentWindow, m_queue, m_textDisplay, and ecvColor::red().
Referenced by setAutoRefresh().
|
static |
Releases unique instance.
Definition at line 90 of file ecvConsole.cpp.
References CVLog::RegisterInstance(), and s_console.
Referenced by ccCommandLineParser::Parse(), and MainWindow::~MainWindow().
| void ecvConsole::setAutoRefresh | ( | bool | state | ) |
Sets auto-refresh state.
Definition at line 214 of file ecvConsole.cpp.
References m_timer, and refresh().
Referenced by setLogFile().
| bool ecvConsole::setLogFile | ( | const QString & | logPrefix | ) |
Sets log file with prefix (generates timestamped log file like glog)
| logPrefix | log file prefix (e.g., "ACloudviewer") |
Definition at line 454 of file ecvConsole.cpp.
References cloudViewer::core::Append(), QtCompat::endl(), CVLog::Error(), generateLogFileName(), getLogDirectory(), m_logFile, m_logStream, m_mutex, CVLog::Print(), and setAutoRefresh().
Referenced by ~ecvConsole().
|
static |
Returns the (unique) static instance.
| autoInit | automatically initialize the console instance (with no widget!) if not done already |
Definition at line 81 of file ecvConsole.cpp.
References ecvConsole(), CVLog::RegisterInstance(), and s_console.
|
protected |
Log file.
Definition at line 127 of file ecvConsole.h.
Referenced by logMessage(), refresh(), and setLogFile().
|
protected |
Log file stream.
Definition at line 129 of file ecvConsole.h.
Referenced by logMessage(), refresh(), and setLogFile().
|
protected |
Mutex for concurrent thread access to console.
Definition at line 115 of file ecvConsole.h.
Referenced by logMessage(), refresh(), and setLogFile().
|
protected |
Parent widget.
Definition at line 109 of file ecvConsole.h.
Referenced by logMessage(), and parentWidget().
|
protected |
|
protected |
Queue for incoming messages.
Definition at line 121 of file ecvConsole.h.
Referenced by logMessage(), and refresh().
|
protected |
Associated text display widget.
Definition at line 106 of file ecvConsole.h.
Referenced by logMessage(), and refresh().
|
protected |
Timer for auto-refresh.
Definition at line 124 of file ecvConsole.h.
Referenced by setAutoRefresh().
|
staticprotected |
Definition at line 133 of file ecvConsole.h.
Referenced by Init(), and logMessage().
|
staticprotected |
Whether to show Qt messages (qDebug / qWarning / etc.) in Console.
Definition at line 132 of file ecvConsole.h.
Referenced by EnableQtMessages(), Init(), and QtMessagesEnabled().