|
Lines 37-42
Link Here
|
| 37 |
#include <ycp/YCPVoid.h> |
37 |
#include <ycp/YCPVoid.h> |
| 38 |
|
38 |
|
| 39 |
#include <zypp/ZYppFactory.h> |
39 |
#include <zypp/ZYppFactory.h> |
|
|
40 |
#include <zypp/base/Logger.h> |
| 41 |
#include <zypp/base/LogControl.h> |
| 40 |
|
42 |
|
| 41 |
// sleep |
43 |
// sleep |
| 42 |
#include <unistd.h> |
44 |
#include <unistd.h> |
|
Lines 49-54
Link Here
|
| 49 |
|
51 |
|
| 50 |
const zypp::ResStatus::TransactByValue PkgFunctions::whoWantsIt = zypp::ResStatus::APPL_HIGH; |
52 |
const zypp::ResStatus::TransactByValue PkgFunctions::whoWantsIt = zypp::ResStatus::APPL_HIGH; |
| 51 |
|
53 |
|
|
|
54 |
struct YaSTZyppLogger : public zypp::base::LogControl::LineWriter |
| 55 |
{ |
| 56 |
virtual void writeOut( const std::string & formated_r ) |
| 57 |
{ |
| 58 |
// don't log empty (debug) messages |
| 59 |
if (!formated_r.empty()) |
| 60 |
{ |
| 61 |
y2lograw((formated_r+"\n").c_str()); |
| 62 |
} |
| 63 |
} |
| 64 |
}; |
| 65 |
|
| 66 |
struct YaSTZyppFormatter : public zypp::base::LogControl::LineFormater |
| 67 |
{ |
| 68 |
virtual std::string format( const std::string & group_r, |
| 69 |
zypp::base::logger::LogLevel level_r, |
| 70 |
const char * file_r, |
| 71 |
const char * func_r, |
| 72 |
int line_r, |
| 73 |
const std::string & message_r ) |
| 74 |
{ |
| 75 |
if (get_log_debug() || level_r > zypp::base::logger::E_DBG) |
| 76 |
{ |
| 77 |
// call the default implementation |
| 78 |
return zypp::base::LogControl::LineFormater::format(group_r, level_r, file_r, func_r, line_r, message_r); |
| 79 |
} |
| 80 |
|
| 81 |
// return empty string (ignore debug messages when debug is tuned off) |
| 82 |
return std::string(); |
| 83 |
} |
| 84 |
|
| 85 |
}; |
| 86 |
|
| 87 |
extern "C" { |
| 88 |
PkgFunctions * createPkgFunctions () { |
| 89 |
return new PkgFunctions (); |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 52 |
/** |
93 |
/** |
| 53 |
* Constructor. |
94 |
* Constructor. |
| 54 |
*/ |
95 |
*/ |
|
Lines 59-64
Link Here
|
| 59 |
,_callbackHandler( *new CallbackHandler(*this) ) |
100 |
,_callbackHandler( *new CallbackHandler(*this) ) |
| 60 |
,target_log_set(false) |
101 |
,target_log_set(false) |
| 61 |
{ |
102 |
{ |
|
|
103 |
y2milestone("Redirecting ZYPP log to y2log"); |
| 104 |
boost::shared_ptr<YaSTZyppLogger> myLogger( new YaSTZyppLogger ); |
| 105 |
zypp::base::LogControl::instance().setLineWriter( myLogger ); |
| 106 |
boost::shared_ptr<YaSTZyppFormatter> myFormatter( new YaSTZyppFormatter ); |
| 107 |
zypp::base::LogControl::instance().setLineFormater( myFormatter ); |
| 108 |
|
| 62 |
const char *domain = "pkg-bindings"; |
109 |
const char *domain = "pkg-bindings"; |
| 63 |
bindtextdomain( domain, LOCALEDIR ); |
110 |
bindtextdomain( domain, LOCALEDIR ); |
| 64 |
bind_textdomain_codeset( domain, "utf8" ); |
111 |
bind_textdomain_codeset( domain, "utf8" ); |