app.log - Log API
Logging API. Each plugin has its own independent log file.
Methods
app.log.verbose(message)
Writes a verbose log entry (plugin log only).
app.log.verbose("Verbose debug information")
app.log.debug(message)
Writes a debug log entry (plugin log only).
app.log.debug("Debug information")
app.log.info(message)
Writes an info log entry (plugin log only).
app.log.info("Processing started")
app.log.warning(message)
Writes a warning log entry (plugin log + system log).
app.log.warning("File not found, using default value")
app.log.warn(message)
Alias for warning.
app.log.warn("Warning message")
app.log.error(message)
Writes an error log entry (plugin log + system log).
app.log.error("Processing failed: " .. err)
app.log.getPath()
Gets the plugin log file path.
Returns: string - Log file path
local path = app.log.getPath()
-- "~/Library/Group Containers/.../Logs/Plugins/com.example.plugin.log"
app.log.read(lines?)
Reads the last N lines of the log file.
Parameters:
lines(number, optional) - Number of lines to read (default 100)
Returns: string - Log content
local content = app.log.read(50)
app.log.clear()
Clears the plugin log file.
app.log.clear()
Log Levels
| Level | Plugin Log | System Log |
|---|---|---|
| verbose | ✅ | ❌ |
| debug | ✅ | ❌ |
| info | ✅ | ❌ |
| warning | ✅ | ✅ |
| error | ✅ | ✅ |
Log Locations
- Plugin log:
~/Library/Group Containers/group.net.ymlab.iRightMenu.pro/Logs/Plugins/{plugin_id}.log - System log:
~/Library/Group Containers/group.net.ymlab.iRightMenu.pro/Logs/iRightMenu.log
Examples
Logging an operation
function MyPlugin:handleConvert(context)
app.log.info("Starting conversion, " .. #context.selectedFiles .. " files total")
for i, file in ipairs(context.selectedFiles) do
app.log.debug("Processing file: " .. file)
local ok, err = self:convertFile(file)
if ok then
app.log.info("Conversion successful: " .. app.path.basename(file))
else
app.log.error("Conversion failed: " .. file .. " - " .. err)
end
end
app.log.info("Conversion complete")
end