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 24 *
25 25 * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
26 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 48 #include <pw3270/plugin.h>
51 49 #include "v3270/accessible.h"
52 50 #include <stdlib.h>
  51 +#include <lib3270/log.h>
53 52  
54 53 #if defined( HAVE_SYSLOG )
55 54 #include <syslog.h>
... ... @@ -65,7 +64,6 @@
65 64 static const gchar * systype = NULL;
66 65 static const gchar * toggleset = NULL;
67 66 static const gchar * togglereset = NULL;
68   - static const gchar * logfile = NULL;
69 67 static const gchar * charset = NULL;
70 68 static const gchar * remap = NULL;
71 69 static const gchar * model = NULL;
... ... @@ -76,11 +74,11 @@
76 74 GtkOSXApplication * osxapp = NULL;
77 75 #endif // HAVE_GTKMAC
78 76  
  77 +/*
79 78 #if defined( HAVE_SYSLOG )
80 79 static gboolean log_to_syslog = FALSE;
81 80 #endif // HAVE_SYSLOG
82   -
83   -
  81 +*/
84 82  
85 83 /*--[ Implement ]------------------------------------------------------------------------------------*/
86 84  
... ... @@ -161,8 +159,9 @@ static gboolean optcolors(const gchar *option_name, const gchar *value, gpointer
161 159 return FALSE;
162 160 }
163 161  
  162 +/*
164 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 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 173 { G_LOG_FLAG_RECURSION, LOG_INFO, "recursion" },
175 174 { G_LOG_FLAG_FATAL, LOG_ERR, "fatal error" },
176 175  
177   - /* GLib log levels */
  176 + // GLib log levels
178 177 { G_LOG_LEVEL_ERROR, LOG_ERR, "error" },
179 178 { G_LOG_LEVEL_CRITICAL, LOG_ERR, "critical error" },
180 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 205 syslog(LOG_INFO,"%s %s",log_domain ? log_domain : "", message);
207 206 }
208 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 215 static gboolean startup(GtkWidget *toplevel)
... ... @@ -379,12 +370,15 @@ int main(int argc, char *argv[])
379 370 { "application-name", 'A', 0, G_OPTION_ARG_STRING, &app_name, N_( "Application name" ), NULL },
380 371 #endif // APPLICATION_NAME
381 372  
  373 +/*
382 374 #if defined( HAVE_SYSLOG )
383 375 { "syslog", 'l', 0, G_OPTION_ARG_NONE, &log_to_syslog, N_( "Send messages to syslog" ), NULL },
384 376 #endif
  377 +*/
385 378 { "tracefile", 'T', 0, G_OPTION_ARG_FILENAME, &tracefile, N_( "Set trace filename" ), NULL },
  379 +/*
386 380 { "log", 'L', 0, G_OPTION_ARG_FILENAME, &logfile, N_( "Log to file" ), NULL },
387   -
  381 +*/
388 382 { NULL }
389 383 };
390 384  
... ... @@ -442,23 +436,26 @@ int main(int argc, char *argv[])
442 436 // Init GTK
443 437 gtk_init(&argc, &argv);
444 438  
  439 + g_log_set_default_handler(g_log_to_lib3270,NULL);
  440 +
  441 +/*
445 442 #if defined( HAVE_SYSLOG )
446 443 if(log_to_syslog)
447 444 {
448 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 447 #endif // HAVE_SYSLOG
455   - {
456   - g_log_set_default_handler(g_logfile,NULL);
  448 +*/
  449 +
457 450  
458 451 #ifdef _WIN32
  452 + {
459 453 g_autofree gchar * appdir = g_win32_get_package_installation_directory_of_module(NULL);
460 454  
461 455 g_message("Windows Application directory is \"%s\"",appdir);
  456 +
  457 + g_chdir(appdir);
  458 +
462 459 g_message("Application name is \"%s\"", g_get_application_name());
463 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 463 g_message("Registry path is \"HKCU\\%s\"",PACKAGE_NAME);
467 464 #endif // ENABLE_WINDOWS_REGISTRY
468 465  
469   -#endif // _WIN32
470   -
471   -
472 466 }
  467 +#endif // _WIN32
473 468  
474 469 // Check GTK Version
475 470 {
... ...