Dev.to AI ๐Ÿค– Ai ๐Ÿ‘ 0 ๐Ÿ“– 6 min read

What Should I Record to Debug My PDF Reader?

My iPad PDF reader could open documents, turn pages, and search for text. As I added features, I also needed a better way to investigate problems. Which device was running the app? Which OS and app versions were involve

What Should I Record to Debug My PDF Reader?

My iPad PDF reader could open documents, turn pages, and search for text. As I added features, I also needed a better way to investigate problems.

Which device was running the app? Which OS and app versions were involved? What happened just before the display became incorrect or a process slowed down?

Those details might be clear while I was testing. Reconstructing them later from memory was harder.

In Part 4, I described restoring reading sessions and preferences, along with testing external PDF imports. This time, I look at the device diagnostics and event logging I added to help investigate problems.

This is a retrospective based mainly on development logs from August through October 2026 and code inspected while preparing the original Japanese article. I have not rerun the appโ€™s build or tests for this post.

Put the environment next to the result

In October, I asked Codex to add a basic diagnostic check that could run inside the app.

The request covered more than a button to start the checks. I wanted a results screen, a way to share the results, and enough context to identify the environment: when the checks were run, device information, OS version, and app version.

The implementation inspected for the original article checked:

  • App version information.
  • Reading and writing in the cache directory.
  • Available storage.
  • Loading a small, temporarily generated PDF.

This brought basic checks and their execution environment into one report.

The scope was limited, though. Generating and loading a one-page PDF did not establish that a 1,100-page document would remain responsive. It also did not verify page order in a two-page layout or the correctness of search results.

In Part 3, I used PDFs with known contents and expected results. Those tests and the in-app diagnostics answered different questions.

Two debugging tools: device diagnostics describe the environment and basic operations, while an event log records actions and processing over time. Neither replaces tests with known inputs and expected results.

Figure 1. Device diagnostics provide context about the environment and basic operations. An event log helps reconstruct what happened before a problem. Both complement tests with known inputs and expected results.

Choose which device information to share

My initial request included the deviceโ€™s name.

After Codex pointed out that a device name could contain a personโ€™s name, I asked to replace it with model information. I also explicitly excluded serial numbers.

Looking back, I had listed a convenient identifier before deciding what the diagnostic report actually needed.

For the problems I wanted to investigate, the device model and OS version were useful starting points. Whether I needed a user-assigned device name was a separate question.

The AI suggestion prompted me to revisit the design. I later checked the API behavior while preparing the original article, keeping that documentation check separate from the explanation given during development.

Appleโ€™s documentation describes different behavior for UIDevice.name depending on the OS version and whether a specific entitlement is present. Saying that the API always returns a personal device name would also be inaccurate.

My lesson was to check what an API returns and decide separately what to collect, display, and share.

I also requested that the results screen explain that diagnostic results were not automatically sent outside the app. Sharing was an action the user could choose from the results screen. That decision belonged in the featureโ€™s design too.

Design the logging interface around what it should accept

Device diagnostics could describe the environment, but they could not show the sequence of actions leading up to a problem.

I therefore asked for event logging to help investigate issues such as incorrect rendering and slow processing. Alongside that purpose, I specified that personal information and file contents should not be recorded.

One detail stood out in the implementation I inspected: callers did not pass arbitrary messages into the appโ€™s logging interface.

Instead, they supplied a predefined event, such as the start of document loading or the completion of a search. They could also attach a duration or a numeric measurement.

โ€œSearch completedโ€ and โ€œthe words the user searched forโ€ are different pieces of information. Recording the first does not necessarily require recording the second.

The logging function I inspected had no parameters for file names or search terms.

That gave the request to exclude certain information a concrete form in the interface. It did not prove that unintended data could never enter a log, but it made the intended inputs easier to inspect than an interface accepting any string.

A vertical logging flow: an app action produces a predefined event, optionally accompanied by a duration or numeric value, which is stored in the in-app log. Search terms, file names and paths, and PDF contents are not accepted by this interface.

Figure 2. The logging interface accepts predefined events and structured measurements. It has no parameters for search terms, file names or paths, or PDF contents. The event names shown here are explanatory examples.

Read the retention behavior, not just the number

Logs also needed a size limit. In my request, I specified removing entries older than 24 hours to prevent the log from growing indefinitely.

The inspected implementation used two limits for the in-app log: a 24-hour window and a maximum of 2,000 entries.

But โ€œremove entries after 24 hoursโ€ needs a more precise explanation.

The implementation filtered retained entries when recording or retrieving logs and saved the resulting set. It did not run a continuous background task that deleted each entry at the exact moment it reached 24 hours.

The destination mattered as well. Predefined event messages were also written through the OS logging system. The retention rules for the app-managed log were not a guarantee about the lifetime of all OS log records.

I learned to look beyond the requested number and check where data was stored and when the retention rules were applied.

Interpret an AI code review within its scope

Before adding the diagnostics and logging features, I had also asked Codex to check the app for vulnerabilities.

The response reported that it had found no high- or medium-risk vulnerabilities in the app implementation.

That was a result to interpret carefully.

The records describe a review of the code available at the time, including areas such as external inputs, file access, and communication-related behavior. They do not document a comprehensive security scan using dedicated tools.

When preparing the original article, I also found no recorded request to test input handling with malformed input or extremely long search terms.

โ€œNo issue was foundโ€ does not establish that every relevant failure mode was tested.

The review gave me an opportunity to name concerns and revisit the code. To assess its result, I still needed to keep track of which code was reviewed, which areas were considered, and which tests had not been performed.

Three tools and their limits: device diagnostics check the environment and basic operations; event logs show the recorded sequence; code reviews provide findings for reviewed code. They do not establish correct behavior for every PDF, identify a root cause on their own, or guarantee overall app security.

Figure 3. Diagnostics, event logs, and code reviews provide different kinds of evidence. Each can support an investigation, but its findings should stay within the scope of what was checked.

Decide what an investigation will need

Adding diagnostics and logs helped me think about how I would explain and investigate a problem after encountering it.

For a similar feature now, I would start with three decisions:

  1. Record the environment and actions. Leave enough context to reconstruct the conditions and steps involved.
  2. Choose what to exclude. Decide which information is needed and what the user may share.
  3. Keep the scope beside the result. A diagnostic success or review finding should not silently become a claim about untested behavior.

AI helped implement these features and raised questions I had missed. Evaluating those suggestions still required reading the code and documentation and keeping track of what had actually been checked.

If a problem appeared in your app, what information would you need to start investigating it?

Source and code: Adapted and reorganized from my Japanese development article on Qiita. The source code is available on GitHub.

This article draws mainly on development logs from August through October 2026 and the testing branch at commit 91f0853, inspected for the original article. The repository includes later changes. This post does not report a new build, test run, or security assessment.

AI disclosure: I used AI assistance to organize and draft this English article and to help create the explanatory diagrams. The development experiences and verification results described here are based on my records.

๐Ÿ“ฐ Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.