Using Script Debugger Logging for long strings

With Script Editor, I am used to reporting data with several 10’s of records, such as a report of all the EXIF data in an image file, or a list of images with broken links, by telling Script Editor to “log” a long string with an embedded “return” character after each line (record). This makes a fairly readable output in the vent log that I can copy parts of.

I have so far been unable to achieve a similar result with Script Debugger. I can log a long string with embedded returns or line feeds, but it is still a single line, with returns replaced by “\r” The Event Explorer window gives no information at all.

If I copy the event to a Text edit document, I haven’t found any way to replace the \r characters with a return or a linefeed.

I’ve tried converting the string to a list, and logging the list, but that seems to be even less useful, there is no indication where the line ends.

Has anyone found a clever way to do this?

A typiclal string (a part of it) might be like this (the \r are generated by SD in place or returns):
\r==========\r[ExifTool] ExifToolVersion : 10.94\r[File] FileName : GM5-16_0121.RW2\r[File] Directory : /Volumes/SSD_ss1/evSSD/Photos/2016 Misc\r[File] FileSize : 19 MB\r[File] FileModifyDate : 2016:12:26 14:19:44-05:00\r[File] FileAccessDate : 2019:01:02 19:56:04-05:00

and what I would like to see is like this:

[ExifTool]      ExifToolVersion                 : 10.94
[File]          FileName                        : GM5-16_0121.RW2
[File]          Directory                       : /Volumes/SSD_ss1/evSSD/Photos/2016 Misc
[File]          FileSize                        : 19 MB
[File]          FileModifyDate                  : 2016:12:26 14:19:44-05:100: 
[File]          FileAccessDate                  : 2019:01:02 19:56:04-05:00

It should be a simple find/replace. Search for \r and either paste in a return for the Replace value, or click on the magnifying glass symbol and choose Insert pattern to insert a paragraph break.

But is there some reason you can’t use the Results & Variables tab instead of the Event Log?

I had missed the “insert pattern” option, OK, got it.

Perhaps I’ve gone about this in a less than efficent way; what I’ve done is written two handlers that I use in many of my scripts. One is “InitialiseLoqqing()”, the the other is loq_Results().
(I have omitted the arguments, and I intentionally use loq, not log, in the name).

See for example

The first handler initialises logging for one or more targets {Clipboard, Notification, Dialog, TextEdit file, ScriptEditor/Debugger event log}.

loq_Results() is called whenever something needs to be logged.

When the script ends, whatever was logged is in the target(s), but no longer in any of the variables of the script. The last data to be logged will have been in a variable local to the the loq_Results() handler.

Since I’m fairly new to Script Debugger I was wondering if had overlooked some simple way of viewing these kinds of long results in the event log; I guess that I have not.

Since I already have a working logging function to TextEdit, probably my easiest way forward is to use that for normal results, and tweak the code so that only errors and status are dropped in the event log.

If you want to log in any detail, then yes, writing/adding to your own file is the best way.

You can enhance your logging function to put out separate log statement per \r.

I been working in applescript for awhile now and have developed my own routines for debugging.

Don’t know where this snafu developed.

log “Welcome” & return & “World!”
will produce two output lines in script editor.


-- ------------------------------------------------------
textToList seems to be what you are trying to do
  thisText is the input string
  delim is what to split on

  returns a list of strings.  

- textToList was found here:


on textToList(thisText, delim)
	global debug
	if debug ≥ 5 then log "in ~~~ textToList ~~~"
	set resultList to {}
	set {tid, my text item delimiters} to {my text item delimiters, delim}
		set resultList to every text item of thisText
		set my text item delimiters to tid
	on error
		set my text item delimiters to tid
	end try
	return resultList
end textToList