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 | 50 | #include <stdlib.h> |
51 | 51 | #include <lib3270/log.h> |
52 | 52 | |
53 | -#if defined( HAVE_SYSLOG ) | |
54 | - #include <syslog.h> | |
55 | -#endif // HAVE_SYSLOG | |
56 | - | |
57 | 53 | #define ERROR_DOMAIN g_quark_from_static_string(PACKAGE_NAME) |
58 | 54 | |
59 | 55 | /*--[ Statics ]--------------------------------------------------------------------------------------*/ |
... | ... | @@ -74,12 +70,6 @@ |
74 | 70 | GtkOSXApplication * osxapp = NULL; |
75 | 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 | 73 | /*--[ Implement ]------------------------------------------------------------------------------------*/ |
84 | 74 | |
85 | 75 | static int initialize(void) |
... | ... | @@ -159,54 +149,6 @@ static gboolean optcolors(const gchar *option_name, const gchar *value, gpointer |
159 | 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 | 152 | static void g_log_to_lib3270(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data) |
211 | 153 | { |
212 | 154 | lib3270_write_log(NULL,log_domain,"%s",message); |
... | ... | @@ -256,6 +198,9 @@ int main(int argc, char *argv[]) |
256 | 198 | setlocale( LC_ALL, "" ); |
257 | 199 | #endif |
258 | 200 | |
201 | + // Log to syslog (if available) | |
202 | + lib3270_set_syslog(1); | |
203 | + | |
259 | 204 | // OS |
260 | 205 | #if defined( _WIN32 ) |
261 | 206 | { |
... | ... | @@ -370,15 +315,7 @@ int main(int argc, char *argv[]) |
370 | 315 | { "application-name", 'A', 0, G_OPTION_ARG_STRING, &app_name, N_( "Application name" ), NULL }, |
371 | 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 | 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 | 319 | { NULL } |
383 | 320 | }; |
384 | 321 | ... | ... |