Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZO-859: Log XML body after checkout to aid debugging #625

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading