Skip to content

Commit

Permalink
Merge pull request #625 from ZeitOnline/ZO-859-debug
Browse files Browse the repository at this point in the history
ZO-859: Log XML body after checkout to aid debugging
  • Loading branch information
wosc authored Feb 19, 2024
2 parents 049fe08 + 30d10b5 commit 2fc9501
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/docs/changelog/ZO-859.change
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ZO-859: Log XML body after checkout to aid debugging
13 changes: 13 additions & 0 deletions core/src/zeit/cms/checkout/manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import logging

import grokcore.component as grok
import lxml.etree
import pendulum
import zope.app.locking.interfaces
import zope.cachedescriptors.property
Expand All @@ -8,6 +11,7 @@
import zope.interface
import zope.security.proxy

from zeit.cms.content.interfaces import IXMLRepresentation
from zeit.cms.i18n import MessageFactory as _
import zeit.cms.checkout.interfaces
import zeit.cms.interfaces
Expand All @@ -17,6 +21,9 @@
import zeit.objectlog.interfaces


log = logging.getLogger(__name__)


@zope.component.adapter(zeit.cms.interfaces.ICMSContent)
@zope.interface.implementer(
zeit.cms.checkout.interfaces.ICheckoutManager, zeit.cms.checkout.interfaces.ICheckinManager
Expand Down Expand Up @@ -102,6 +109,12 @@ def checkout(self, event=True, temporary=False, publishing=False):
)
)

# XXX Debug helper, see ZO-859
log_body = config.get('checkout-log-body', '').lower() == 'true'
if log_body and IXMLRepresentation.providedBy(added):
body = lxml.etree.tostring(added.xml, pretty_print=True, encoding=str)
log.info('%s checked out %s:\n%s', self.principal.id, added, body)

return workingcopy[name]

@property
Expand Down

0 comments on commit 2fc9501

Please sign in to comment.