summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2023-04-30 03:07:35 -0600
committerDan Allen <dan.j.allen@gmail.com>2023-04-30 03:07:35 -0600
commit5499356f0552b7d1010f849cea5c3a90ab3e15ae (patch)
tree38bdf1806d2c650d5551d30bc8427bf87f351296 /docs
parente29edeedd76cea90e5fc4524bebda34bb60ac1b8 (diff)
correctly access reader from document object in extension
Diffstat (limited to 'docs')
-rw-r--r--docs/modules/extensions/pages/logging.adoc6
1 files changed, 3 insertions, 3 deletions
diff --git a/docs/modules/extensions/pages/logging.adoc b/docs/modules/extensions/pages/logging.adoc
index 329f93ca..06381988 100644
--- a/docs/modules/extensions/pages/logging.adoc
+++ b/docs/modules/extensions/pages/logging.adoc
@@ -140,16 +140,16 @@ Let's look at how to do that.
In addition to the `logger` method, Asciidoctor's `Logging` module also adds a helper named `message_with_context` that generates a message object that bundles source information with the string message.
-For block and block macro extensions, you probably want to reference the location where the block is found, which you can retrieve using the `parent.reader.cursor_at_mark` method call.
+For block and block macro extensions, you probably want to reference the location where the block is found, which you can retrieve using the `parent.document.reader.cursor_at_mark` method call.
For a tree processor extension, you can retrieve the source location from the `source_location` method on the block.
-For most other extensions, you likely want to reference the current cursor, which is accessible from `parent.reader.cursor` or (`doc.reader` for extensions that only provide access to the document object).
+For most other extensions, you likely want to reference the current cursor, which is accessible from `parent.document.reader.cursor` or (`doc.reader` for extensions that only provide access to the document object).
Here's an example that replaces the message with an object that includes the source location:
[,ruby]
----
logger.warn(%(#{logger.progname} (custom-block-extension))) {
- message_with_context 'Something is out of sorts.', source_location: parent.reader.cursor_at_mark
+ message_with_context 'Something is out of sorts.', source_location: parent.document.reader.cursor_at_mark
}
----