diff --git a/src/oxt/globals.hpp b/src/oxt/globals.hpp index 0329cd1..e681665 100644 --- a/src/oxt/globals.hpp +++ b/src/oxt/globals.hpp @@ -70,6 +70,8 @@ void sleep(int seconds = 1); + void log(const char *fmt, const char *msg); + rtl_TextEncoding get_encoding(); }; @@ -145,6 +147,7 @@ virtual ::sal_Int16 SAL_CALL sleep( ::sal_Int16 seconds ) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getTextAt( ::sal_Int16 row, ::sal_Int16 col, ::sal_Int16 size ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int16 SAL_CALL setTextAt( ::sal_Int16 row, ::sal_Int16 col, const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL log(const ::rtl::OUString& text ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int16 SAL_CALL enter( ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int16 SAL_CALL pfkey( ::sal_Int16 keycode ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int16 SAL_CALL pakey( ::sal_Int16 keycode ) throw (::com::sun::star::uno::RuntimeException); diff --git a/src/oxt/local.cxx b/src/oxt/local.cxx index c0f32cb..7320a73 100644 --- a/src/oxt/local.cxx +++ b/src/oxt/local.cxx @@ -32,6 +32,11 @@ #include "globals.hpp" #include + #ifdef HAVE_SYSLOG + #include + #include + #endif // HAVE_SYSLOG + /* * NOTE: Take a better look at osl_createEmptySocketAddr() & osl_connectSocketTo() to see if there's * a way to use this calls to connect with the host for better performance. @@ -42,6 +47,15 @@ /*---[ Implement ]-----------------------------------------------------------------------------------------*/ +static void loghandler(H3270 *session, const char *module, int rc, const char *fmt, va_list args) +{ +#ifdef HAVE_SYSLOG + openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER); + vsyslog(LOG_INFO,fmt,args); + closelog(); +#endif // HAVE_SYSLOG +} + pw3270::lib3270_session::lib3270_session() { struct _call @@ -64,6 +78,7 @@ }; H3270 * (*lib3270_new)(const char *); + void (*set_log_handler)(void (*loghandler)(H3270 *, const char *, int, const char *, va_list)); hThread = NULL; hSession = NULL; @@ -77,9 +92,15 @@ *call[f].entry = (void *) osl_getAsciiFunctionSymbol(hModule,call[f].name); /* Get lib3270 session handle */ + set_log_handler = (void (*)(void (*loghandler)(H3270 *, const char *, int, const char *, va_list))) osl_getAsciiFunctionSymbol(hModule,"lib3270_set_log_handler"); + + if(set_log_handler) + set_log_handler(loghandler); + lib3270_new = (H3270 * (*)(const char *)) osl_getAsciiFunctionSymbol(hModule,"lib3270_session_new"); hSession = lib3270_new(""); + log("%s UNO extension loaded",PACKAGE_NAME); } pw3270::lib3270_session::~lib3270_session() @@ -105,6 +126,7 @@ hModule = NULL; } + log("%s UNO extension unloaded",PACKAGE_NAME); } int pw3270::lib3270_session::get_revision(void) diff --git a/src/oxt/main.cxx b/src/oxt/main.cxx index a2311fe..ca9f1f9 100644 --- a/src/oxt/main.cxx +++ b/src/oxt/main.cxx @@ -31,6 +31,10 @@ #include "globals.hpp" +#ifdef HAVE_SYSLOG + #include +#endif // HAVE_SYSLOG + #include #include #include @@ -229,6 +233,12 @@ pw3270::uno_impl::~uno_impl() return 0; } +::sal_Int16 SAL_CALL pw3270::uno_impl::log( const ::rtl::OUString& msg ) throw (::com::sun::star::uno::RuntimeException) +{ + hSession->log("%s",rtl::OUStringToOString(msg,RTL_TEXTENCODING_UTF8).getStr()); + return 0; +} + pw3270::session::session() { @@ -251,4 +261,14 @@ void pw3270::session::sleep(int seconds) osl_waitThread(&t); } +void pw3270::session::log(const char *fmt, const char *msg) +{ +#ifdef HAVE_SYSLOG + openlog(PACKAGE_NAME, LOG_NDELAY, LOG_USER); + syslog(LOG_INFO,fmt,msg); + closelog(); +#else + #error This module needs syslog support +#endif // HAVE_SYSLOG +} diff --git a/src/oxt/pw3270.idl b/src/oxt/pw3270.idl index 90abe9b..fa54edb 100644 --- a/src/oxt/pw3270.idl +++ b/src/oxt/pw3270.idl @@ -75,6 +75,7 @@ module br /* Misc */ short getRevision(); + short log([in] string msg); short sleep([in] short seconds); boolean isReady(); boolean hasTextAt([in] short row, [in] short col, [in] string text); -- libgit2 0.21.2