I’m developing an app with Corona on iOS 6 beta 1/2 and I’m not seeing any console output from my app in Xcode organizer. I have “io.output():setvbuf(‘no’)” in my main.lua file, and it was previously working in iOS 5. Is this a known issue? Any workarounds? [import]uid: 131129 topic_id: 28591 reply_id: 328591[/import]
I came up with a way to do remote logging as a temporary workaround for this issue. It uses Parse.com as a backend to receive the log entries from your app. After requiring this script all further print calls will show up on Parse.com as members of whatever class you specify in the script. Parse already timestamps class creation and sorts entries by date/time so their online browser should be good enough for basic use.
[lua]-- Parse.com logging for Corona SDK
– Require this script in your project and all further print calls will be sent
– to the Parse.com class that you specifiy in the settings below
– DISCLAIMER OF WARRANTY
– This source code is provided “as is” and without warranties as to performance
– or merchantability. The author and/or distributors of this source code may
– have made statements about this source code. Any such statements do not
– constitute warranties and shall not be relied on by the user in deciding
– whether to use this source code.
– This source code is provided without any express or implied warranties
– whatsoever. Because of the diversity of conditions and hardware under which
– this source code may be used, no warranty of fitness for a particular purpose
– is offered. The user is advised to test the source code thoroughly before
– relying on it. The user must assume the entire risk of using the source code.
– User settings –
– Enable this if you want this library to log debug information to the console
local DEBUG = false
– The name of the Parse.com class that you want log entries to be sent to
local className = “LogEntry”
– your Parse.com Application ID
local applicationId = “PUT YOUR APPLICATION ID HERE”
– Your Parse.com REST API Key
local restKey = “PUT YOUR REST API KEY HERE”
– End User settings –
– You shouldn’t need to touch anything below this line
local headers = {}
headers[“X-Parse-Application-Id”] = applicationId
headers[“X-Parse-REST-API-Key”] = restKey
headers[“Content-type”] = “application/json”
local value = require(“json”)
local baseUrl = “https://api.parse.com/1/classes/”
if DEBUG then
_print = print
else
_print = function() end
end
local function networkListener(event)
local response = nil
if (event.isError) then
_print(“Network error”)
else
_print(“Status code:”, event.status)
for k, v in pairs(event) do
_print(k, v)
end
response = value.decode(event.response)
if response.error then
for k, v in pairs(response) do
_print(k, v)
end
end
end
end
local function remoteLog(str)
if str then
local payload = {body = str}
local params = {
headers = headers,
body = value.encode(payload)
}
local requestUrl = baseUrl … className
_print(requestUrl)
network.request(requestUrl, “POST”, networkListener, params)
end
end
print = function(…)
remoteLog(table.concat({…}, “\t”))
end[/lua] [import]uid: 131129 topic_id: 28591 reply_id: 115226[/import]