Use a file in the user directory for stdout and stderr on Windows

issue11390
review397911002
This commit is contained in:
Nicolas Évrard committed 2022-04-11 16:37:34 +02:00
1 parent 0e76db05e7
commit 5ade55babe
4 files changed
+13 -7

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Add option to define logging output location
* Remove TreeViewControl
* Manage optional column
* Default CSV encoding to UTF8 with BOM
-4
View File
@@ -11,10 +11,6 @@ except NameError:
pass
if hasattr(sys, 'frozen'):
if not ('-v' in sys.argv or '--verbose' in sys.argv or
'-l' in sys.argv or '--log-level' in sys.argv):
sys.stdout = open(os.devnull, 'w')
sys.stderr = open(os.devnull, 'w')
prefix = os.path.dirname(sys.executable)
os.environ['GTK_EXE_PREFIX'] = prefix
os.environ['GTK_DATA_PREFIX'] = prefix
+3
View File
@@ -38,6 +38,9 @@ Options
-l LOG_LEVEL, --log-level=LOG_LEVEL Specify the log level: DEBUG, INFO,
WARNING, ERROR, CRITICAL
-o LOG_OUTPUT, --log-ouput=LOG_OUTPUT Specify the file used to output logging
information
-u LOGIN, --user=LOGIN Specify the login user
-s SERVER, --server=SERVER Specify the server hostname:port
+9 -3
View File
@@ -84,6 +84,8 @@ class ConfigManager(object):
parser.add_option("-l", "--log-level", dest="log_level",
help=_("specify the log level: "
"DEBUG, INFO, WARNING, ERROR, CRITICAL"))
parser.add_option("-o", "--log-ouput", dest="log_output", default=None,
help=_("specify the file used to output logging information"))
parser.add_option("-u", "--user", dest="login",
help=_("specify the login user"))
parser.add_option("-s", "--server", dest="host",
@@ -93,8 +95,10 @@ class ConfigManager(object):
get_config_dir(), 'tryton.conf')
self.load()
self.options['dev'] = opt.dev
logging.basicConfig()
logging_config = {}
if opt.log_output:
logging_config['filename'] = opt.log_output
loglevels = {
'DEBUG': logging.DEBUG,
'INFO': logging.INFO,
@@ -107,8 +111,10 @@ class ConfigManager(object):
opt.log_level = 'INFO'
else:
opt.log_level = 'ERROR'
logging.getLogger().setLevel(loglevels[opt.log_level.upper()])
logging_config['level'] = loglevels[opt.log_level.upper()]
logging.basicConfig(**logging_config)
self.options['dev'] = opt.dev
for arg in ['login', 'host']:
if getattr(opt, arg):
self.options['login.' + arg] = getattr(opt, arg)