[IMP]: allow Log level to be changed in runtime.

Export an RPC method and let a simple client change the log level. This
helps when we want to debug the server without restarting it.

bzr revid: p_christ@hol.gr-20090814101822-pu2ed3249b6m30v8
This commit is contained in:
P. Christeas 2009-08-14 13:18:22 +03:00
parent 75e9560f9c
commit 00d15e79fe
3 changed files with 37 additions and 0 deletions

View File

@ -193,6 +193,12 @@ class Logger(object):
# better ignore the exception and carry on..
pass
def set_loglevel(self, level):
log = logging.getLogger()
log.setLevel(logging.INFO) # make sure next msg is printed
log.info("Log level changed to %s" % logging.getLevelName(level))
log.setLevel(level)
def shutdown(self):
logging.shutdown()

View File

@ -375,6 +375,7 @@ class common(netsvc.Service):
self.exportMethod(self.get_migration_scripts)
self.exportMethod(self.get_server_environment)
self.exportMethod(self.login_message)
self.exportMethod(self.set_loglevel)
def ir_set(self, db, uid, password, keys, args, name, value, replace=True, isobject=False):
security.check(db, uid, password)
@ -561,6 +562,12 @@ GNU Public Licence.
def login_message(self):
return tools.config.get('login_message', False)
def set_loglevel(self, password, loglevel):
security.check_super(password)
l = netsvc.Logger()
l.set_loglevel(int(loglevel))
return True
common()
class objects_proxy(netsvc.Service):

24
change-loglevel.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
ADMIN_PASSWD='admin'
method_1() {
cat '-' << EOF
<xml>
<methodCall>
<methodName>set_loglevel</methodName>
<params>
<param><value><string>$ADMIN_PASSWD</string></value>
</param>
<param>
<value><string>$1</string></value>
</param>
</params>
</methodCall>
EOF
}
LEVEL=10
if [ -n "$1" ] ; then LEVEL=$1 ; fi
method_1 $LEVEL | POST -c 'text/xml' http://localhost:8069/xmlrpc/common
#eof