Solo es una cosa pequeña, supongo, pero me molesta ver errores reportados en la consola para mis AppleScripts donde el texto del mensaje de error contiene caracteres de sustitución. por ej.
Número de error: -43 Mensaje de error: No se puede completar la operación.
En el mensaje de error "can’t" ha sido reemplazado por "canÕt"
No estoy seguro si esto es un fallo de AppleScript, la shell o console.app.
He intentado las rutas habituales de examinar console.app (sin configuración), Configuración del Sistema (idioma y regiones y caracteres del teclado parecen no afectar la salida de la consola).
Este ejemplo demuestra el problema:
set appName to "textTester"
set targetFolder to "Virtuality:Users:minmin:Documents:" -- un destino inexistente fuerza el error
try
tell application "System Events"
set theResult to name of every file of targetFolder
end tell
on error errMsg number errNum
set logEntry to (línea nueva & errNum & espacio & errMsg & línea nueva) as texto
tell me to writeToLogFile(logEntry, appName) -- los mensajes de error generados por AppleScript en sí crean el problema
tell me to writeToLogFile("¿Quién hubiera pensado que no puedo registrar este texto correctamente?", appName) -- demuestra que escribir directamente en el log está bien
end try
on writeToLogFile(logEntry, appName)
local handlerName
set handlerName to "writeToLogFile"
set theDate to do shell script "date '+_%Y_%m_%d'"
set theDate1st to do shell script "date '+_%Y_%m'" --real date 1st would be "date '+_%m_1_%Y'"
set libPath to path to library folder from user domain as string
set theFolderPath to (libPath & "Logs:") as string
set theFilePath to (theFolderPath & appName & ":") as string
set theFileName to (appName & theDate1st & ".log")
set theFile to (theFilePath & theFileName)
try
set okToContinue to false
tell application "Finder"
--asegurarse de que la carpeta está ahí
if (not (exists folder theFilePath)) then
make new folder at theFolderPath with properties {name:appName}
end if
--asegurarse de que el archivo de registro está allí - o darlo vuelta
if (not (exists theFile)) then
set theFile to make new file at theFilePath with properties {name:theFileName, file type:"TEXT", creator type:"ttxt"}
end if
--abrir y escribir entradas de registro
set theFile to theFile as alias
tell me
set writetoTheThing to open for access theFile with write permission
write (logEntry & return) to writetoTheThing starting at eof
close access (writetoTheThing)
end tell
set okToContinue to true
end tell
on error errMsg number errNum
log errMsg
end try
return okToContinue
end writeToLogFile
¿Hay realmente una solución?