def _log(self, msg, level=logging.INFO): """ Log with prefix to application log. Prefix includes view name, site name, context path, username Timestamps are not in prefix, included by logging framework. Example prefix: WorkspaceMembership: [mysite] /mysite/a/b ([email protected]) -- """ if not hasattr(self, 'authuser'): self.authuser = self.mtool.getAuthenticatedMember().getUserName() view_cls = self.__class__ if view_cls.__name__.startswith('SimpleViewClass'): view_cls = self.__class__.__bases__[0] # work-around Five magic site = self.portal.getId() if isinstance(msg, unicode): msg = msg.encode('utf-8') prefix = '%s: [%s] %s (%s) -- ' % ( view_cls.__name__, site, '/'.join(self.context.getPhysicalPath()), self.authuser, ) msg = '%s %s' % (prefix, msg) APP_LOG.log(level, msg)
def _log(self, msg, level=logging.INFO): site = '[%s]' % self.portal.getId() if isinstance(msg, unicode): msg = msg.encode('utf-8') msg = '%s %s' % (site, msg) # prefix with site-name all messages APP_LOG.log(level, msg)