Add commandline option to show warnings
This commit is contained in:
		
							parent
							
								
									1b975172d6
								
							
						
					
					
						commit
						b5c98864ad
					
				
					 1 changed files with 18 additions and 0 deletions
				
			
		
							
								
								
									
										18
									
								
								src/gajim.py
									
										
									
									
									
								
							
							
						
						
									
										18
									
								
								src/gajim.py
									
										
									
									
									
								
							| 
						 | 
					@ -94,6 +94,9 @@ class GajimApplication(Gtk.Application):
 | 
				
			||||||
        self.add_main_option('loglevel', ord('l'), GLib.OptionFlags.NONE,
 | 
					        self.add_main_option('loglevel', ord('l'), GLib.OptionFlags.NONE,
 | 
				
			||||||
                             GLib.OptionArg.STRING,
 | 
					                             GLib.OptionArg.STRING,
 | 
				
			||||||
                             _('Configure logging system'), 'LEVEL')
 | 
					                             _('Configure logging system'), 'LEVEL')
 | 
				
			||||||
 | 
					        self.add_main_option('warnings', ord('w'), GLib.OptionFlags.NONE,
 | 
				
			||||||
 | 
					                             GLib.OptionArg.NONE,
 | 
				
			||||||
 | 
					                             _('Show all warnings'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.profile = ''
 | 
					        self.profile = ''
 | 
				
			||||||
        self.config_path = None
 | 
					        self.config_path = None
 | 
				
			||||||
| 
						 | 
					@ -286,6 +289,8 @@ class GajimApplication(Gtk.Application):
 | 
				
			||||||
        if options.contains('loglevel'):
 | 
					        if options.contains('loglevel'):
 | 
				
			||||||
            loglevel = options.lookup_value('loglevel').get_string()
 | 
					            loglevel = options.lookup_value('loglevel').get_string()
 | 
				
			||||||
            logging_helpers.set_loglevels(loglevel)
 | 
					            logging_helpers.set_loglevels(loglevel)
 | 
				
			||||||
 | 
					        if options.contains('warnings'):
 | 
				
			||||||
 | 
					            self.show_warnings()
 | 
				
			||||||
        return -1
 | 
					        return -1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def do_command_line(self, command_line: Gio.ApplicationCommandLine) -> int:
 | 
					    def do_command_line(self, command_line: Gio.ApplicationCommandLine) -> int:
 | 
				
			||||||
| 
						 | 
					@ -294,6 +299,19 @@ class GajimApplication(Gtk.Application):
 | 
				
			||||||
            self.activate()
 | 
					            self.activate()
 | 
				
			||||||
        return 0
 | 
					        return 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def show_warnings(self):
 | 
				
			||||||
 | 
					        import traceback
 | 
				
			||||||
 | 
					        import warnings
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def warn_with_traceback(message, category, filename, lineno,
 | 
				
			||||||
 | 
					                                file=None, line=None):
 | 
				
			||||||
 | 
					            traceback.print_stack(file=sys.stderr)
 | 
				
			||||||
 | 
					            sys.stderr.write(warnings.formatwarning(message, category,
 | 
				
			||||||
 | 
					                                                    filename, lineno, line))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        warnings.showwarning = warn_with_traceback
 | 
				
			||||||
 | 
					        warnings.filterwarnings(action="always")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def frozen_logging(self, path):
 | 
					    def frozen_logging(self, path):
 | 
				
			||||||
        import warnings
 | 
					        import warnings
 | 
				
			||||||
        if not os.path.exists(path):
 | 
					        if not os.path.exists(path):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue