Author: sh-sh-sh
Date: Wed Jan 23 18:34:20 2008
New Revision: 43853
URL: http://svn.opensuse.org/viewcvs/yast?rev=43853&view=rev
Log:
use new logging
Modified:
trunk/qt/src/YQUIComponent.h
trunk/qt/src/YQUI_builtins.cc
trunk/qt/src/YQUI_core.cc
trunk/qt/src/YQUI_widgets.cc
trunk/qt/src/YQUI_x11.cc
trunk/qt/src/utf8.h
Modified: trunk/qt/src/YQUIComponent.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQUIComponent.h?rev=43853&r1=43852&r2=43853&view=diff
==============================================================================
--- trunk/qt/src/YQUIComponent.h (original)
+++ trunk/qt/src/YQUIComponent.h Wed Jan 23 18:34:20 2008
@@ -19,9 +19,6 @@
#ifndef YQUIComponent_h
#define YQUIComponent_h
-#define y2log_component "qt-ui"
-#include
-
#include
#include "YQUI.h"
Modified: trunk/qt/src/YQUI_builtins.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQUI_builtins.cc?rev=43853&r1=43852&r2=43853&view=diff
==============================================================================
--- trunk/qt/src/YQUI_builtins.cc (original)
+++ trunk/qt/src/YQUI_builtins.cc Wed Jan 23 18:34:20 2008
@@ -32,8 +32,8 @@
#include <QInputDialog>
#include
-#define y2log_component "qt-ui"
-#include
+#define YUILogComponent "qt-ui"
+#include "YUILog.h"
#include "YQUI.h"
#include "YEvent.h"
@@ -55,7 +55,7 @@
YCPValue YQUI::runPkgSelection( YWidget * packageSelector )
{
- y2milestone( "Running package selection..." );
+ yuiMilestone() << "Running package selection..." << endl;
YCPValue input = YCPVoid();
try
@@ -64,16 +64,18 @@
}
catch (const std::exception & e)
{
- y2error( "Caught std::exception: %s", e.what() );
- y2error( "This is a libzypp problem. Do not file a bug against the UI!" );
+ yuiError() << "Caught std::exception: %s" << e.what() << "\n"
+ << "This is a libzypp problem. Do not file a bug against the UI!"
+ << endl;
}
catch (...)
{
- y2error( "Caught unspecified exception." );
- y2error( "This is a libzypp problem. Do not file a bug against the UI!" );
+ yuiError() << "Caught unspecified exception.\n"
+ << "This is a libzypp problem. Do not file a bug against the UI!"
+ << endl;
}
- y2milestone( "Package selection done - returning %s", input->toString().c_str() );
+ yuiMilestone() << "Package selection done. Returning " << input->toString() << endl;
return input;
}
@@ -81,7 +83,6 @@
void YQUI::makeScreenShot( std::string stl_filename )
{
-
//
// Grab the pixels off the screen
//
@@ -106,8 +107,8 @@
//
QString home = QDir::homePath();
- char * ssdir = getenv("Y2SCREENSHOTS");
- QString dir = ssdir ? ssdir : "yast2-screen-shots";
+ char * ssdir = getenv( "Y2SCREENSHOTS" );
+ QString dir = ssdir ? fromUTF8( ssdir ) : "yast2-screen-shots";
if ( home == "/" )
{
@@ -120,7 +121,7 @@
dir = "/tmp/" + dir;
- if ( mkdir( qPrintable(dir), 0700 ) == -1 )
+ if ( mkdir( toUTF8( dir ).c_str(), 0700 ) == -1 )
dir = "";
}
else
@@ -130,7 +131,7 @@
// chance to create symlinks to a better location if he wishes so.
dir = home + "/" + dir;
- (void) mkdir( qPrintable(dir), 0750 );
+ (void) mkdir( toUTF8( dir ).c_str(), 0750 );
}
screenShotNameTemplate = dir + "/%s-%03d.png";
@@ -142,10 +143,12 @@
//
const char * baseName = moduleName();
- if ( ! baseName ) baseName = "scr";
+ if ( ! baseName )
+ baseName = "scr";
+
int no = screenShotNo[ baseName ];
- fileName.sprintf( qPrintable(screenShotNameTemplate), baseName, no );
- y2debug( "screenshot: %s", qPrintable(fileName) );
+ fileName.sprintf( qPrintable( screenShotNameTemplate ), baseName, no );
+ yuiDebug() << "Screenshot: " << fileName << endl;
{
YQSignalBlocker sigBlocker( _user_input_timer );
@@ -157,7 +160,7 @@
if ( fileName.isEmpty() )
{
- y2debug( "Save screen shot canceled by user" );
+ yuiDebug() << "Save screen shot canceled by user" << endl;
return;
}
@@ -169,12 +172,12 @@
// Actually save the screen shot
//
- y2debug( "Saving screen shot to %s", qPrintable(fileName) );
+ yuiDebug() << "Saving screen shot to " << fileName << endl;
bool success = screenShot.save( fileName, "PNG" );
if ( ! success )
{
- y2error( "Couldn't save screen shot %s", qPrintable(fileName) );
+ yuiError() << "Couldn't save screen shot " << fileName << endl;
if ( interactive )
{
@@ -191,7 +194,7 @@
{
macroRecorder->beginBlock();
YDialog::currentDialog()->saveUserInput( macroRecorder );
- macroRecorder->recordMakeScreenShot( true, qPrintable(fileName) );
+ macroRecorder->recordMakeScreenShot( true, toUTF8( fileName ) );
macroRecorder->recordUserInput( YCPVoid() );
macroRecorder->endBlock();
}
@@ -211,13 +214,15 @@
if ( access( saveLogsCommand.toAscii(), X_OK ) == 0 )
{
saveLogsCommand += " '" + fileName + "'";
- y2milestone( "Saving y2logs: %s", qPrintable(saveLogsCommand) );
- int result = system( qPrintable(saveLogsCommand) );
+ yuiMilestone() << "Saving y2logs: " << saveLogsCommand << endl;
+ int result = system( qPrintable( saveLogsCommand) );
if ( result != 0 )
{
- y2error( "Error saving y2logs: \"%s\" exited with %d",
- qPrintable(saveLogsCommand), result );
+ yuiError() << "Error saving y2logs: \"" << saveLogsCommand
+ << "\" exited with " << result
+ << endl;
+
QMessageBox::warning( 0, // parent
"Error", // caption
QString( "Couldn't save y2logs to %1 - "
@@ -228,13 +233,14 @@
}
else
{
- y2milestone( "y2logs saved to %s", qPrintable(fileName) );
+ yuiMilestone() << "y2logs saved to " << fileName << endl;
}
}
else
{
- y2error( "Error saving y2logs: Command %s not found",
- qPrintable(saveLogsCommand) );
+ yuiError() << "Error saving y2logs: Command \""
+ << saveLogsCommand << "\" not found"
+ << endl;
QMessageBox::warning( 0, // parent
"Error", // caption
@@ -252,18 +258,21 @@
{
bool okButtonPressed = false;
QStringList items;
- items << "Debug logging off"
- << "Debug logging on";
+ items << "UI Debug logging off"
+ << "UI Debug logging on";
QString result = QInputDialog::getItem( _main_win,
- _("YaST2 Logging"),
- _("Configure YaST2 Logging:"),
- items, 0, get_log_debug() ? 1 : 0, &okButtonPressed);
+ _("YaST2 UI Logging"),
+ _("Configure YaST2 UI Logging:"),
+ items, 0,
+ YUILog::debugLoggingEnabled() ? 1 : 0,
+ &okButtonPressed );
if ( okButtonPressed )
{
- set_log_debug( result.endsWith( "on" ) );
- y2milestone( "Changing logging: %s - %s", qPrintable(result),
- get_log_debug() ? "y2debug on" : "y2debug off" );
+ YUILog::enableDebugLogging( result.endsWith( "on" ) );
+ yuiMilestone() << "Changing logging: <<" << result
+ << " UI Debug logging: " << YUILog::debugLoggingEnabled()
+ << endl;
}
}
@@ -295,7 +304,7 @@
if ( ! filename.isEmpty() ) // file selection dialog has been cancelled
{
- recordMacro( qPrintable(filename) );
+ recordMacro( toUTF8( filename ) );
}
}
}
@@ -314,7 +323,7 @@
if ( ! filename.isEmpty() ) // file selection dialog has been cancelled
{
- playMacro( qPrintable(filename) );
+ playMacro( toUTF8( filename ) );
// Do special magic to get out of any UserInput() loop right now
// without doing any harm - otherwise this would hang until the next
Modified: trunk/qt/src/YQUI_core.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQUI_core.cc?rev=43853&r1=43852&r2=43853&view=diff
==============================================================================
--- trunk/qt/src/YQUI_core.cc (original)
+++ trunk/qt/src/YQUI_core.cc Wed Jan 23 18:34:20 2008
@@ -19,6 +19,7 @@
#include // MAXHOSTNAMELEN
#include
#include
+#include <algorithm>
#include <QCursor>
#include <QMessageBox>
@@ -28,8 +29,8 @@
#include <QThread>
#include <QVBoxLayout>
-#define y2log_component "qt-ui"
-#include
+#define YUILogComponent "qt-ui"
+#include "YUILog.h"
#include "YQUI.h"
#include "QY2Styler.h"
@@ -43,11 +44,15 @@
#include "YQDialog.h"
#include "QY2Settings.h"
+
+using std::max;
+
#define BUSY_CURSOR_TIMEOUT 200 // milliseconds
-YQUI * YQUI::_ui = 0;
static void qMessageHandler( QtMsgType type, const char * msg );
+YQUI * YQUI::_ui = 0;
+
YQUI::YQUI( int argc, char **argv, bool with_threads, const char * macro_file )
: YUI( with_threads )
@@ -55,7 +60,7 @@
, _do_exit_loop( false )
, _eventLoop( 0 )
{
- y2milestone( "YQUI constructor start" );
+ yuiMilestone() << "YQUI constructor start" << endl;
_ui = this;
_fatal_error = false;
@@ -90,7 +95,7 @@
void YQUI::init_ui()
{
- if (_ui_inited)
+ if ( _ui_inited )
return;
// yast has no use of the glib event loop
@@ -192,8 +197,9 @@
QString qt_lib_name = QString( QTLIBDIR "/libQtGui.so.%1" ).arg( QT_VERSION >> 16 );;
void * qt_lib = dlopen( qt_lib_name.toUtf8().constData(), RTLD_GLOBAL );
- y2milestone( "Forcing %s open %s", qt_lib_name.toUtf8().constData(),
- qt_lib ? "successful" : "failed" );
+ yuiMilestone() << "Forcing " << qt_lib_name.toUtf8().constData() << " open "
+ << ( qt_lib ? "successful" : "failed" )
+ << endl;
// Init other stuff
@@ -210,7 +216,9 @@
// if ( macro_file )
// playMacro( macro_file );
- y2milestone( "YQUI constructor end %ld", QThread::currentThreadId () );
+ yuiMilestone() << "YQUI constructor end. Thread ID: "
+ << hex << QThread::currentThreadId () << dec
+ << endl;
qApp->processEvents();
}
@@ -230,7 +238,7 @@
{
QString opt = argv[i];
- y2milestone ("Qt argument: %s", argv[i]);
+ yuiMilestone() << "Qt argument: " << argv[i] << endl;
// Normalize command line option - accept "--xy" as well as "-xy"
@@ -272,7 +280,7 @@
YQUI::~YQUI()
{
- y2debug("Closing down Qt UI.");
+ yuiDebug() <<"Closing down Qt UI." << endl;
normalCursor();
@@ -327,8 +335,10 @@
{
_default_size = availableSize;
- y2milestone( "-fullscreen: using %dx%d for `opt(`defaultsize)",
- _default_size.width(), _default_size.height() );
+ yuiMilestone() << "-fullscreen: using "
+ << _default_size.width() << " x " << _default_size.height()
+ << "for `opt(`defaultsize)"
+ << endl;
}
else
{
@@ -359,12 +369,15 @@
}
else
{
- y2milestone( "Forced size (via -geometry): %dx%d",
- _default_size.width(), _default_size.height() );
+ yuiMilestone() << "Forced size (via -geometry): "
+ << _default_size.width() << " x " << _default_size.height()
+ << endl;
}
}
- y2milestone( "Default size: %dx%d", _default_size.width(), _default_size.height() );
+ yuiMilestone() << "Default size: "
+ << _default_size.width() << " x " << _default_size.height()
+ << endl;
}
@@ -436,7 +449,11 @@
_eventLoop->wakeUp();
blocked_level = 0;
- //y2milestone( "userInput %ld %ld", timeout_millisec, QThread::currentThreadId() );
+#if 0
+ yuiMilestone() << "userInput( " << timeout_millisec
+ << " ) Thread ID: " << hex << QThread::currentThreadId() << dec
+ << endl;
+#endif
YEvent * event = 0;
YQDialog * dialog = dynamic_cast ( YDialog::currentDialog( false ) );
@@ -584,24 +601,24 @@
switch (type)
{
case QtDebugMsg:
- y2milestone ("qt-debug: %s\n", msg);
+ yuiMilestone() << "<qt-debug> " << msg << endl;
break;
case QtWarningMsg:
- y2warning ("qt-warning: %s\n", msg);
+ yuiWarning() << "<qt-warning> " << msg << endl;
#ifndef NDEBUG
//abort();
#endif
break;
case QtCriticalMsg:
- y2warning ("qt-critical: %s\n", msg);
+ yuiError() << "<qt-critical>" << msg << endl;
#ifndef NDEBUG
//abort();
#endif
break;
case QtFatalMsg:
- y2internal ("qt-fatal: %s\n", msg);
+ yuiError() << "<qt-fatal> " << msg << endl;
abort();
- exit (1); // qt does the same
+ exit(1); // qt does the same
}
}
Modified: trunk/qt/src/YQUI_widgets.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQUI_widgets.cc?rev=43853&r1=43852&r2=43853&view=diff
==============================================================================
--- trunk/qt/src/YQUI_widgets.cc (original)
+++ trunk/qt/src/YQUI_widgets.cc Wed Jan 23 18:34:20 2008
@@ -16,8 +16,8 @@
/-*/
-#define y2log_component "qt-ui"
-#include
+#define YUILogComponent "qt-ui"
+#include "YUILog.h"
#include <QDesktopWidget>
#include "YQUI.h"
Modified: trunk/qt/src/YQUI_x11.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/YQUI_x11.cc?rev=43853&r1=43852&r2=43853&view=diff
==============================================================================
--- trunk/qt/src/YQUI_x11.cc (original)
+++ trunk/qt/src/YQUI_x11.cc Wed Jan 23 18:34:20 2008
@@ -29,8 +29,8 @@
#include <QDesktopWidget>
-#define y2log_component "qt-ui"
-#include
+#define YUILogComponent "qt-ui"
+#include "YUILog.h"
#include "YEvent.h"
#include "YQDialog.h"
@@ -235,7 +235,7 @@
_leftHandedMouse = ! _leftHandedMouse; // might be set repeatedly!
_askedForLeftHandedMouse = false; // give the user a chance to switch back
- y2milestone( "Switching mouse buttons: %s", command );
+ yuiMilestone() << "Switching mouse buttons: " << command << endl;
system( command );
}
Modified: trunk/qt/src/utf8.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/qt/src/utf8.h?rev=43853&r1=43852&r2=43853&view=diff
==============================================================================
--- trunk/qt/src/utf8.h (original)
+++ trunk/qt/src/utf8.h Wed Jan 23 18:34:20 2008
@@ -22,11 +22,12 @@
#include
#include <string>
+#include <iosfwd>
inline QString fromUTF8( const std::string & str )
{
- return QString::fromUtf8(str.c_str() );
+ return QString::fromUtf8( str.c_str() );
}
@@ -38,4 +39,11 @@
return std::string( str.toUtf8().data() );
}
+
+inline std::ostream & operator<<( std::ostream & stream, const QString & str )
+{
+ return stream << str.toUtf8().data();
+}
+
+
#endif // utf8_h
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org