Commit 2ec229897a775f225cabc02048262add2b1bc427
1 parent
1a5926b3
Exists in
master
and in
5 other branches
linux log is now sent do system log.
Showing
1 changed file
with
3 additions
and
66 deletions
Show diff stats
src/pw3270/main.c
@@ -50,10 +50,6 @@ | @@ -50,10 +50,6 @@ | ||
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include <lib3270/log.h> | 51 | #include <lib3270/log.h> |
52 | 52 | ||
53 | -#if defined( HAVE_SYSLOG ) | ||
54 | - #include <syslog.h> | ||
55 | -#endif // HAVE_SYSLOG | ||
56 | - | ||
57 | #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME) | 53 | #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME) |
58 | 54 | ||
59 | /*--[ Statics ]--------------------------------------------------------------------------------------*/ | 55 | /*--[ Statics ]--------------------------------------------------------------------------------------*/ |
@@ -74,12 +70,6 @@ | @@ -74,12 +70,6 @@ | ||
74 | GtkOSXApplication * osxapp = NULL; | 70 | GtkOSXApplication * osxapp = NULL; |
75 | #endif // HAVE_GTKMAC | 71 | #endif // HAVE_GTKMAC |
76 | 72 | ||
77 | -/* | ||
78 | -#if defined( HAVE_SYSLOG ) | ||
79 | - static gboolean log_to_syslog = FALSE; | ||
80 | -#endif // HAVE_SYSLOG | ||
81 | -*/ | ||
82 | - | ||
83 | /*--[ Implement ]------------------------------------------------------------------------------------*/ | 73 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
84 | 74 | ||
85 | static int initialize(void) | 75 | static int initialize(void) |
@@ -159,54 +149,6 @@ static gboolean optcolors(const gchar *option_name, const gchar *value, gpointer | @@ -159,54 +149,6 @@ static gboolean optcolors(const gchar *option_name, const gchar *value, gpointer | ||
159 | return FALSE; | 149 | return FALSE; |
160 | } | 150 | } |
161 | 151 | ||
162 | -/* | ||
163 | -#if defined( HAVE_SYSLOG ) | ||
164 | -static void g_log_to_syslog(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data) | ||
165 | -{ | ||
166 | - static const struct _logtype | ||
167 | - { | ||
168 | - GLogLevelFlags log_level; | ||
169 | - int priority; | ||
170 | - const gchar * msg; | ||
171 | - } logtype[] = | ||
172 | - { | ||
173 | - { G_LOG_FLAG_RECURSION, LOG_INFO, "recursion" }, | ||
174 | - { G_LOG_FLAG_FATAL, LOG_ERR, "fatal error" }, | ||
175 | - | ||
176 | - // GLib log levels | ||
177 | - { G_LOG_LEVEL_ERROR, LOG_ERR, "error" }, | ||
178 | - { G_LOG_LEVEL_CRITICAL, LOG_ERR, "critical error" }, | ||
179 | - { G_LOG_LEVEL_WARNING, LOG_ERR, "warning" }, | ||
180 | - { G_LOG_LEVEL_MESSAGE, LOG_ERR, "message" }, | ||
181 | - { G_LOG_LEVEL_INFO, LOG_INFO, "info" }, | ||
182 | - { G_LOG_LEVEL_DEBUG, LOG_DEBUG, "debug" }, | ||
183 | - }; | ||
184 | - | ||
185 | - int f; | ||
186 | - | ||
187 | - for(f=0;f<G_N_ELEMENTS(logtype);f++) | ||
188 | - { | ||
189 | - if(logtype[f].log_level == log_level) | ||
190 | - { | ||
191 | - gchar *ptr; | ||
192 | - gchar *text = g_strdup_printf("%s: %s %s",logtype[f].msg,log_domain ? log_domain : "",message); | ||
193 | - for(ptr = text;*ptr;ptr++) | ||
194 | - { | ||
195 | - if(*ptr < ' ') | ||
196 | - *ptr = ' '; | ||
197 | - } | ||
198 | - | ||
199 | - syslog(logtype[f].priority,"%s",text); | ||
200 | - g_free(text); | ||
201 | - return; | ||
202 | - } | ||
203 | - } | ||
204 | - | ||
205 | - syslog(LOG_INFO,"%s %s",log_domain ? log_domain : "", message); | ||
206 | -} | ||
207 | -#endif // HAVE_SYSLOG | ||
208 | -*/ | ||
209 | - | ||
210 | static void g_log_to_lib3270(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data) | 152 | static void g_log_to_lib3270(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data) |
211 | { | 153 | { |
212 | lib3270_write_log(NULL,log_domain,"%s",message); | 154 | lib3270_write_log(NULL,log_domain,"%s",message); |
@@ -256,6 +198,9 @@ int main(int argc, char *argv[]) | @@ -256,6 +198,9 @@ int main(int argc, char *argv[]) | ||
256 | setlocale( LC_ALL, "" ); | 198 | setlocale( LC_ALL, "" ); |
257 | #endif | 199 | #endif |
258 | 200 | ||
201 | + // Log to syslog (if available) | ||
202 | + lib3270_set_syslog(1); | ||
203 | + | ||
259 | // OS | 204 | // OS |
260 | #if defined( _WIN32 ) | 205 | #if defined( _WIN32 ) |
261 | { | 206 | { |
@@ -370,15 +315,7 @@ int main(int argc, char *argv[]) | @@ -370,15 +315,7 @@ int main(int argc, char *argv[]) | ||
370 | { "application-name", 'A', 0, G_OPTION_ARG_STRING, &app_name, N_( "Application name" ), NULL }, | 315 | { "application-name", 'A', 0, G_OPTION_ARG_STRING, &app_name, N_( "Application name" ), NULL }, |
371 | #endif // APPLICATION_NAME | 316 | #endif // APPLICATION_NAME |
372 | 317 | ||
373 | -/* | ||
374 | -#if defined( HAVE_SYSLOG ) | ||
375 | - { "syslog", 'l', 0, G_OPTION_ARG_NONE, &log_to_syslog, N_( "Send messages to syslog" ), NULL }, | ||
376 | -#endif | ||
377 | -*/ | ||
378 | { "tracefile", 'T', 0, G_OPTION_ARG_FILENAME, &tracefile, N_( "Set trace filename" ), NULL }, | 318 | { "tracefile", 'T', 0, G_OPTION_ARG_FILENAME, &tracefile, N_( "Set trace filename" ), NULL }, |
379 | -/* | ||
380 | - { "log", 'L', 0, G_OPTION_ARG_FILENAME, &logfile, N_( "Log to file" ), NULL }, | ||
381 | -*/ | ||
382 | { NULL } | 319 | { NULL } |
383 | }; | 320 | }; |
384 | 321 |