Commit 1a5926b3bae4ed0efc11a39f28d8a64e6e60e6dc

Authored by Perry Werneck
1 parent f1f0360f

Removing logfile option.

Showing 1 changed file with 23 additions and 28 deletions   Show diff stats
src/pw3270/main.c
@@ -24,8 +24,6 @@ @@ -24,8 +24,6 @@
24 * 24 *
25 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) 25 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) 26 * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
27 - * licinio@bb.com.br (Licínio Luis Branco)  
28 - * kraucer@bb.com.br (Kraucer Fernandes Mazuco)  
29 * 27 *
30 */ 28 */
31 29
@@ -50,6 +48,7 @@ @@ -50,6 +48,7 @@
50 #include <pw3270/plugin.h> 48 #include <pw3270/plugin.h>
51 #include "v3270/accessible.h" 49 #include "v3270/accessible.h"
52 #include <stdlib.h> 50 #include <stdlib.h>
  51 +#include <lib3270/log.h>
53 52
54 #if defined( HAVE_SYSLOG ) 53 #if defined( HAVE_SYSLOG )
55 #include <syslog.h> 54 #include <syslog.h>
@@ -65,7 +64,6 @@ @@ -65,7 +64,6 @@
65 static const gchar * systype = NULL; 64 static const gchar * systype = NULL;
66 static const gchar * toggleset = NULL; 65 static const gchar * toggleset = NULL;
67 static const gchar * togglereset = NULL; 66 static const gchar * togglereset = NULL;
68 - static const gchar * logfile = NULL;  
69 static const gchar * charset = NULL; 67 static const gchar * charset = NULL;
70 static const gchar * remap = NULL; 68 static const gchar * remap = NULL;
71 static const gchar * model = NULL; 69 static const gchar * model = NULL;
@@ -76,11 +74,11 @@ @@ -76,11 +74,11 @@
76 GtkOSXApplication * osxapp = NULL; 74 GtkOSXApplication * osxapp = NULL;
77 #endif // HAVE_GTKMAC 75 #endif // HAVE_GTKMAC
78 76
  77 +/*
79 #if defined( HAVE_SYSLOG ) 78 #if defined( HAVE_SYSLOG )
80 static gboolean log_to_syslog = FALSE; 79 static gboolean log_to_syslog = FALSE;
81 #endif // HAVE_SYSLOG 80 #endif // HAVE_SYSLOG
82 -  
83 - 81 +*/
84 82
85 /*--[ Implement ]------------------------------------------------------------------------------------*/ 83 /*--[ Implement ]------------------------------------------------------------------------------------*/
86 84
@@ -161,8 +159,9 @@ static gboolean optcolors(const gchar *option_name, const gchar *value, gpointer @@ -161,8 +159,9 @@ static gboolean optcolors(const gchar *option_name, const gchar *value, gpointer
161 return FALSE; 159 return FALSE;
162 } 160 }
163 161
  162 +/*
164 #if defined( HAVE_SYSLOG ) 163 #if defined( HAVE_SYSLOG )
165 -static void g_syslog(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data) 164 +static void g_log_to_syslog(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data)
166 { 165 {
167 static const struct _logtype 166 static const struct _logtype
168 { 167 {
@@ -174,7 +173,7 @@ static void g_syslog(const gchar *log_domain,GLogLevelFlags log_level,const gcha @@ -174,7 +173,7 @@ static void g_syslog(const gchar *log_domain,GLogLevelFlags log_level,const gcha
174 { G_LOG_FLAG_RECURSION, LOG_INFO, "recursion" }, 173 { G_LOG_FLAG_RECURSION, LOG_INFO, "recursion" },
175 { G_LOG_FLAG_FATAL, LOG_ERR, "fatal error" }, 174 { G_LOG_FLAG_FATAL, LOG_ERR, "fatal error" },
176 175
177 - /* GLib log levels */ 176 + // GLib log levels
178 { G_LOG_LEVEL_ERROR, LOG_ERR, "error" }, 177 { G_LOG_LEVEL_ERROR, LOG_ERR, "error" },
179 { G_LOG_LEVEL_CRITICAL, LOG_ERR, "critical error" }, 178 { G_LOG_LEVEL_CRITICAL, LOG_ERR, "critical error" },
180 { G_LOG_LEVEL_WARNING, LOG_ERR, "warning" }, 179 { G_LOG_LEVEL_WARNING, LOG_ERR, "warning" },
@@ -206,19 +205,11 @@ static void g_syslog(const gchar *log_domain,GLogLevelFlags log_level,const gcha @@ -206,19 +205,11 @@ static void g_syslog(const gchar *log_domain,GLogLevelFlags log_level,const gcha
206 syslog(LOG_INFO,"%s %s",log_domain ? log_domain : "", message); 205 syslog(LOG_INFO,"%s %s",log_domain ? log_domain : "", message);
207 } 206 }
208 #endif // HAVE_SYSLOG 207 #endif // HAVE_SYSLOG
  208 +*/
209 209
210 -static void g_logfile(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data) 210 +static void g_log_to_lib3270(const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data)
211 { 211 {
212 - FILE *out = fopen(logfile,"a");  
213 - if(out)  
214 - {  
215 - time_t ltime;  
216 - char wrk[40];  
217 - time(&ltime);  
218 - strftime(wrk, 39, "%d/%m/%Y %H:%M:%S", localtime(&ltime));  
219 - fprintf(out,"%s\t%s\n",wrk,message);  
220 - fclose(out);  
221 - } 212 + lib3270_write_log(NULL,log_domain,"%s",message);
222 } 213 }
223 214
224 static gboolean startup(GtkWidget *toplevel) 215 static gboolean startup(GtkWidget *toplevel)
@@ -379,12 +370,15 @@ int main(int argc, char *argv[]) @@ -379,12 +370,15 @@ int main(int argc, char *argv[])
379 { "application-name", 'A', 0, G_OPTION_ARG_STRING, &app_name, N_( "Application name" ), NULL }, 370 { "application-name", 'A', 0, G_OPTION_ARG_STRING, &app_name, N_( "Application name" ), NULL },
380 #endif // APPLICATION_NAME 371 #endif // APPLICATION_NAME
381 372
  373 +/*
382 #if defined( HAVE_SYSLOG ) 374 #if defined( HAVE_SYSLOG )
383 { "syslog", 'l', 0, G_OPTION_ARG_NONE, &log_to_syslog, N_( "Send messages to syslog" ), NULL }, 375 { "syslog", 'l', 0, G_OPTION_ARG_NONE, &log_to_syslog, N_( "Send messages to syslog" ), NULL },
384 #endif 376 #endif
  377 +*/
385 { "tracefile", 'T', 0, G_OPTION_ARG_FILENAME, &tracefile, N_( "Set trace filename" ), NULL }, 378 { "tracefile", 'T', 0, G_OPTION_ARG_FILENAME, &tracefile, N_( "Set trace filename" ), NULL },
  379 +/*
386 { "log", 'L', 0, G_OPTION_ARG_FILENAME, &logfile, N_( "Log to file" ), NULL }, 380 { "log", 'L', 0, G_OPTION_ARG_FILENAME, &logfile, N_( "Log to file" ), NULL },
387 - 381 +*/
388 { NULL } 382 { NULL }
389 }; 383 };
390 384
@@ -442,23 +436,26 @@ int main(int argc, char *argv[]) @@ -442,23 +436,26 @@ int main(int argc, char *argv[])
442 // Init GTK 436 // Init GTK
443 gtk_init(&argc, &argv); 437 gtk_init(&argc, &argv);
444 438
  439 + g_log_set_default_handler(g_log_to_lib3270,NULL);
  440 +
  441 +/*
445 #if defined( HAVE_SYSLOG ) 442 #if defined( HAVE_SYSLOG )
446 if(log_to_syslog) 443 if(log_to_syslog)
447 { 444 {
448 openlog(g_get_prgname(), LOG_NDELAY, LOG_USER); 445 openlog(g_get_prgname(), LOG_NDELAY, LOG_USER);
449 - g_log_set_default_handler(g_syslog,NULL);  
450 } 446 }
451 - else if(logfile)  
452 -#else  
453 - if(logfile)  
454 #endif // HAVE_SYSLOG 447 #endif // HAVE_SYSLOG
455 - {  
456 - g_log_set_default_handler(g_logfile,NULL); 448 +*/
  449 +
457 450
458 #ifdef _WIN32 451 #ifdef _WIN32
  452 + {
459 g_autofree gchar * appdir = g_win32_get_package_installation_directory_of_module(NULL); 453 g_autofree gchar * appdir = g_win32_get_package_installation_directory_of_module(NULL);
460 454
461 g_message("Windows Application directory is \"%s\"",appdir); 455 g_message("Windows Application directory is \"%s\"",appdir);
  456 +
  457 + g_chdir(appdir);
  458 +
462 g_message("Application name is \"%s\"", g_get_application_name()); 459 g_message("Application name is \"%s\"", g_get_application_name());
463 g_message("Session name is \"%s\"", session_name ? session_name : "undefined"); 460 g_message("Session name is \"%s\"", session_name ? session_name : "undefined");
464 461
@@ -466,10 +463,8 @@ int main(int argc, char *argv[]) @@ -466,10 +463,8 @@ int main(int argc, char *argv[])
466 g_message("Registry path is \"HKCU\\%s\"",PACKAGE_NAME); 463 g_message("Registry path is \"HKCU\\%s\"",PACKAGE_NAME);
467 #endif // ENABLE_WINDOWS_REGISTRY 464 #endif // ENABLE_WINDOWS_REGISTRY
468 465
469 -#endif // _WIN32  
470 -  
471 -  
472 } 466 }
  467 +#endif // _WIN32
473 468
474 // Check GTK Version 469 // Check GTK Version
475 { 470 {