|
@@ -65,7 +65,8 @@ def run_make(target, names):
|
65
|
65
|
|
66
|
66
|
|
67
|
67
|
##@brief Set configuration given args
|
68
|
|
-#@param args as returned by argparse
|
|
68
|
+#@param name str : instance name
|
|
69
|
+#@param args : as returned by argparse
|
69
|
70
|
def set_conf(name, args):
|
70
|
71
|
validate_names([name])
|
71
|
72
|
conffile = get_conffile(name)
|
|
@@ -74,7 +75,7 @@ def set_conf(name, args):
|
74
|
75
|
config = configparser.ConfigParser(interpolation=None)
|
75
|
76
|
config.read(conffile)
|
76
|
77
|
|
77
|
|
-
|
|
78
|
+ #Interface options
|
78
|
79
|
if args.interface is not None:
|
79
|
80
|
iarg = args.interface
|
80
|
81
|
if iarg not in ('web', 'python'):
|
|
@@ -103,7 +104,8 @@ def set_conf(name, args):
|
103
|
104
|
Selected interface is not the web iterface")
|
104
|
105
|
if 'lodel.webui' in config:
|
105
|
106
|
del(config['lodel2.webui'])
|
106
|
|
-
|
|
107
|
+
|
|
108
|
+ #Datasource options
|
107
|
109
|
if args.datasource_connectors is not None:
|
108
|
110
|
darg = args.datasource_connectors
|
109
|
111
|
if darg not in ('dummy', 'mongodb'):
|
|
@@ -144,6 +146,33 @@ Selected interface is not the web iterface")
|
144
|
146
|
config[dbconfname]['db_name'] = str(args.db_name)
|
145
|
147
|
else:
|
146
|
148
|
config['lodel2.datasource.dummy_datasource.default'] = {'dummy':''}
|
|
149
|
+ #Logger options
|
|
150
|
+ if args.set_logger is not None:
|
|
151
|
+ #Purge existing loggers
|
|
152
|
+ for k in [ k for k in config if k.startswith('lodel2.logging.')]:
|
|
153
|
+ del(config[k])
|
|
154
|
+ if isinstance(args.set_logger, str):
|
|
155
|
+ specs = [ args.set_logger ]
|
|
156
|
+ else:
|
|
157
|
+ specs = args.set_logger
|
|
158
|
+ #Add the new one
|
|
159
|
+ for log_spec in specs:
|
|
160
|
+ spl = log_spec.split(':')
|
|
161
|
+ if len(spl) == 3:
|
|
162
|
+ loggername, loglevel, logfile = log_spec.split(':')
|
|
163
|
+ else:
|
|
164
|
+ raise ValueError(
|
|
165
|
+ "Invalid format for logger spec : %s" % log_spec)
|
|
166
|
+
|
|
167
|
+ loggerkey = 'lodel2.logging.%s' % loggername
|
|
168
|
+ if '%s' in logfile:
|
|
169
|
+ logfile = logfile.replace('%s', name)
|
|
170
|
+ if '%l' in logfile:
|
|
171
|
+ logfile = logfile.replace('%l', loglevel.lower())
|
|
172
|
+ config[loggerkey] = {
|
|
173
|
+ 'level': loglevel,
|
|
174
|
+ 'filename': logfile,
|
|
175
|
+ 'context': True }
|
147
|
176
|
#Now config should be OK to be written again in conffile
|
148
|
177
|
with open(conffile, 'w+') as cfp:
|
149
|
178
|
config.write(cfp)
|
|
@@ -494,6 +523,15 @@ to 1 instance")
|
494
|
523
|
help="Select the database name on which datasource will be connect")
|
495
|
524
|
confs.add_argument('--uwsgi-workers', type=int, default='2',
|
496
|
525
|
metavar = 'N', help="Number of workers to spawn at the start of uwsgi")
|
|
526
|
+
|
|
527
|
+ confs.add_argument('--set-logger', type=str, default='default:INFO:-',
|
|
528
|
+ metavar = 'LOGGERSPEC', nargs='*',
|
|
529
|
+ help='Set a logger given a logger spec. A logger spec is a string \
|
|
530
|
+with this form : LOGGERNAME:LOGLEVEL:LOGFILE with LOGLEVEL one of DEBUG, \
|
|
531
|
+INFO, WARNING, SECURITY, ERROR or FATAL. LOGFILE can be a path to a logfile \
|
|
532
|
+or - to indicate stderr, else you can put a "%s" in the string that will \
|
|
533
|
+be replaced by instance name and a "%l" that will be replaced by the \
|
|
534
|
+loglevel.')
|
497
|
535
|
return parser
|
498
|
536
|
|
499
|
537
|
if __name__ == '__main__':
|
|
@@ -591,7 +629,7 @@ specified")
|
591
|
629
|
elif args.set_option:
|
592
|
630
|
names = None
|
593
|
631
|
if args.all:
|
594
|
|
- names = list(get_store_datas().values())
|
|
632
|
+ names = list(get_store_datas().keys())
|
595
|
633
|
elif args.name is not None:
|
596
|
634
|
names = args.name
|
597
|
635
|
if names is None:
|