[IMP] switch workflows to standard logging (silenced by default), remove wkf_logs
authorXavier Morel <xmo@openerp.com>
Tue, 19 Mar 2013 16:31:33 +0000 (17:31 +0100)
committerXavier Morel <xmo@openerp.com>
Tue, 19 Mar 2013 16:31:33 +0000 (17:31 +0100)
bzr revid: xmo@openerp.com-20130319163133-3n1k1hgooddzxntz

openerp/netsvc.py
openerp/workflow/wkf_logs.py [deleted file]
openerp/workflow/workitem.py

index ef72ba1..ffbd38d 100644 (file)
@@ -131,6 +131,7 @@ def init_logger():
 
     # Configure handlers
     default_config = [
+        'openerp.workflow.workitem:WARNING',
         'openerp.netsvc.rpc.request:INFO',
         'openerp.netsvc.rpc.response:INFO',
         'openerp.addons.web.http:INFO',
diff --git a/openerp/workflow/wkf_logs.py b/openerp/workflow/wkf_logs.py
deleted file mode 100644 (file)
index 9463fe6..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#    
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
-#
-#    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as
-#    published by the Free Software Foundation, either version 3 of the
-#    License, or (at your option) any later version.
-#
-#    This program is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU Affero General Public License for more details.
-#
-#    You should have received a copy of the GNU Affero General Public License
-#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
-#
-##############################################################################
-
-#
-# May be uncommented to logs workflows modifications
-#
-
-def log(cr,ident,act_id,info=''):
-    return 
-    #    msg = """
-    #res_type: %r
-    #res_id: %d
-    #uid: %d
-    #act_id: %d
-    #info: %s
-    #""" % (ident[1], ident[2], ident[0], act_id, info)
-
-    #cr.execute('insert into wkf_logs (res_type, res_id, uid, act_id, time, info) values (%s,%s,%s,%s,current_time,%s)', (ident[1],int(ident[2]),int(ident[0]),int(act_id),info))
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
index 06ba367..88a786e 100644 (file)
 # TODO:
 # cr.execute('delete from wkf_triggers where model=%s and res_id=%s', (res_type,res_id))
 #
+import logging
 
 import instance
 
 import wkf_expr
-import wkf_logs
+
+logger = logging.getLogger(__name__)
 
 def create(cr, act_datas, inst_id, ident, stack):
     for act in act_datas:
@@ -36,7 +38,8 @@ def create(cr, act_datas, inst_id, ident, stack):
         cr.execute("insert into wkf_workitem (id,act_id,inst_id,state) values (%s,%s,%s,'active')", (id_new, act['id'], inst_id))
         cr.execute('select * from wkf_workitem where id=%s',(id_new,))
         res = cr.dictfetchone()
-        wkf_logs.log(cr,ident,act['id'],'active')
+        logger.info('Created workflow item in activity %s',
+                    act['id'], extra={'ident': ident})
         process(cr, res, ident, stack=stack)
 
 def process(cr, workitem, ident, signal=None, force_running=False, stack=None):
@@ -75,7 +78,8 @@ def process(cr, workitem, ident, signal=None, force_running=False, stack=None):
 def _state_set(cr, workitem, activity, state, ident):
     cr.execute('update wkf_workitem set state=%s where id=%s', (state,workitem['id']))
     workitem['state'] = state
-    wkf_logs.log(cr,ident,activity['id'],state)
+    logger.info("Changed state of work item %s to \"%s\" in activity %s",
+                workitem['id'], state, activity['id'], extra={'ident': ident})
 
 def _execute(cr, workitem, activity, ident, stack):
     result = True