       reportError(error)
   trixDebugWrapper
 
-wrapTrixMethodsWithErrorHandler = ->
-  for className, constructor of Trix when constructor.prototype instanceof Trix.BasicObject
-    for methodName, method of constructor.prototype when typeof method is "function" and methodName isnt "constructor"
-      constructor::[methodName] = wrapFunctionWithErrorHandler(method)
+installMethodDebugger = (className, methodName) ->
+  [objectName, constructorNames...] = className.split(".")
+  [propertyNames..., methodName] = methodName.split(".")
 
-wrapTrixMethodsWithErrorHandler()
+  object = @[objectName]
+  object = object[constructorName] for constructorName in constructorNames
+  object = object.prototype
+  object = object[propertyName] for propertyName in propertyNames
+
+  if typeof object?[methodName] is "function"
+    object[methodName] = wrapFunctionWithErrorHandler(object[methodName])
+  else
+    throw new Error "Can't install on non-function"
+
+install = ->
+  console.groupCollapsed("Trix debugger")
+
+  for className, methodNames of DEBUG_METHODS
+    for methodName in methodNames.split(/\s/)
+      try
+        installMethodDebugger(className, methodName)
+        console.log "✓ #{className}##{methodName}"
+      catch error
+        console.warn "✗ #{className}##{methodName}:", error.message
+
+  console.groupEnd()
+
+install()

    border: none;
  }
"""

setDebugInfo = ({element, error, focus}) ->
  editorElement = findClosestElementFromNode(element, matchingSelector: "trix-editor")

# This file is not included in the main Trix bundle and
# should be explicitly required to enable the debugger.

DEBUG_METHODS =
  "Trix.AttachmentEditorController": "
    didClickRemoveButton
    uninstall
  "

  "Trix.DocumentController": "
    didClickAttachment
  "

  "Trix.EditorController": "
    setEditor
    loadDocument
  "

  "Trix.ImageAttachmentEditorController": "
    startResize
    resize
    endResize
  "

  "Trix.InputController": "
    elementDidMutate
    events.keydown
    events.keypress
    events.dragstart
    events.dragover
    events.dragend
    events.drop
    events.cut
    events.paste
    events.compositionstart
    events.compositionend
  "

  "Trix.ToolbarController": "
    didClickActionButton
    didClickAttributeButton
    didClickDialogButton
    didKeyDownDialogInput
  "

TrixToolbarElement::constructor.defaultHTML += """
  <span class="button_group">
