Commit 71da01b0 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

Lua: tag all backend messages with [SCRIPT.LUA] where possible

--HG--
branch : lua_fix
parent 7eae4b42eb3d
......@@ -67,7 +67,7 @@ int lua_take_semaphore(lua_State * L, int timeout, struct semaphore ** assoc_sem
return take_semaphore(current->semaphore, timeout);
}
}
fprintf(stderr, "[Lua] error: could not find semaphore for lua state\n");
fprintf(stderr, "[%s] error: could not find semaphore for lua state\n", lua_get_script_filename(L));
return -1;
}
......@@ -82,7 +82,7 @@ int lua_give_semaphore(lua_State * L, struct semaphore ** assoc_semaphore)
return give_semaphore(current->semaphore);
}
}
fprintf(stderr, "[Lua] error: could not find semaphore for lua state\n");
fprintf(stderr, "[%s] error: could not find semaphore for lua state\n", lua_get_script_filename(L));
return -1;
}
......@@ -168,7 +168,7 @@ static unsigned int lua_do_cbr(unsigned int ctx, struct script_event_entry * eve
lua_pushinteger(L, ctx);
if(docall(L, 1, 1))
{
fprintf(stderr, "[Lua] cbr error:\n %s\n", lua_tostring(L, -1));
fprintf(stderr, "[%s] cbr error:\n %s\n", lua_get_script_filename(L), lua_tostring(L, -1));
lua_save_last_error(L);
result = CBR_RET_ERROR;
give_semaphore(sem);
......@@ -191,7 +191,7 @@ static unsigned int lua_do_cbr(unsigned int ctx, struct script_event_entry * eve
}
else
{
printf("[Lua] semaphore timeout: %s (%dms)\n", event_name, timeout);
printf("[%s] semaphore timeout: %s (%dms)\n", lua_get_script_filename(L), event_name, timeout);
}
}
}
......@@ -697,7 +697,7 @@ void lua_set_last_menu(lua_State * L, const char * parent_menu, const char * men
{
if(script->L == L)
{
printf("[Lua] menu: %s - %s\n", parent_menu, menu_entry);
printf("[%s] menu: %s - %s\n", lua_get_script_filename(L), parent_menu, menu_entry);
script->last_menu_parent = parent_menu;
script->last_menu_entry = menu_entry;
}
......@@ -729,7 +729,17 @@ int lua_get_cant_yield(lua_State * L)
return -1;
}
const char * lua_get_script_filename(lua_State * L)
{
for (struct lua_script * script = lua_scripts; script; script = script->next)
{
if(script->L == L)
{
return script->filename;
}
}
return "?";
}
static int lua_get_config_flag_path(struct lua_script * script, char * full_path, const char * flag)
{
......@@ -766,7 +776,7 @@ static void load_script(struct lua_script * script)
{
if(script->L)
{
fprintf(stderr, "[Lua] script is already running\n");
fprintf(stderr, "[%s] script is already running.\n", script->filename);
return;
}
......@@ -795,7 +805,7 @@ static void load_script(struct lua_script * script)
int error = 0;
char full_path[MAX_PATH_LEN];
snprintf(full_path, MAX_PATH_LEN, SCRIPTS_DIR "/%s", script->filename);
printf("[Lua] loading script: %s.\n", script->filename);
printf("[%s] script starting.\n", script->filename);
int status = luaL_loadfile(L, full_path);
if (status == LUA_OK) {
......@@ -826,7 +836,7 @@ static void load_script(struct lua_script * script)
script->state = SCRIPT_STATE_RUNNING_IN_BACKGROUND;
script->menu_entry->icon_type = IT_BOOL;
printf("[Lua] running %s in background.\n", script->filename);
printf("[%s] running in background.\n", script->filename);
}
else
{
......@@ -838,7 +848,7 @@ static void load_script(struct lua_script * script)
script->menu_entry->icon_type = IT_ACTION;
script->state = SCRIPT_STATE_NOT_RUNNING;
script->load_time = 0;
printf("[Lua] script finished: %s.\n\n", script->filename);
printf("[%s] script finished.\n\n", script->filename);
}
}
else
......
......@@ -112,6 +112,8 @@ void lua_set_last_menu(lua_State * L, const char * parent_menu, const char * men
void lua_set_cant_yield(lua_State * L, int cant_yield);
int lua_get_cant_yield(lua_State * L);
const char * lua_get_script_filename(lua_State * L);
int luaCB_next(lua_State * L);
int luaCB_pairs(lua_State * L);
......
......@@ -176,7 +176,7 @@ static int luaCB_lens_autofocus(lua_State * L)
else
{
/* timeout */
printf("[Lua] focus status: %d\n", lv_focus_status);
printf("[%s] focus status: %d\n", lua_get_script_filename(L), lv_focus_status);
goto error;
}
}
......
......@@ -159,7 +159,7 @@ static LVINFO_UPDATE_FUNC(lua_lvinfo_update)
lua_rawgeti(L, LUA_REGISTRYINDEX, entry->self_ref);
if(docall(L, 1, 1))
{
fprintf(stderr, "[Lua] script error:\n %s\n", lua_tostring(L, -1));
fprintf(stderr, "[%s] script error:\n %s\n", lua_get_script_filename(L), lua_tostring(L, -1));
lua_save_last_error(L);
}
}
......@@ -169,7 +169,7 @@ static LVINFO_UPDATE_FUNC(lua_lvinfo_update)
}
else
{
printf("[Lua] semaphore timeout: lv.info.update (%dms)\n", 50);
printf("[%s] semaphore timeout: lv.info.update (%dms)\n", lua_get_script_filename(L), 50);
}
}
......
......@@ -60,20 +60,20 @@ static MENU_SELECT_FUNC(script_menu_select)
lua_pushinteger(L, delta);
if(docall(L, 2, 0))
{
fprintf(stderr, "[Lua] script error:\n %s\n", lua_tostring(L, -1));
fprintf(stderr, "[%s] script error:\n %s\n", lua_get_script_filename(L), lua_tostring(L, -1));
lua_save_last_error(L);
}
give_semaphore(sem);
}
else
{
fprintf(stderr, "[Lua] select is not a function\n");
fprintf(stderr, "[%s] select is not a function\n", lua_get_script_filename(L));
give_semaphore(sem);
}
}
else
{
printf("[Lua] semaphore timeout: menu.select (%dms)\n", 500);
printf("[%s] semaphore timeout: menu.select (%dms)\n", lua_get_script_filename(L), 500);
}
}
}
......@@ -158,7 +158,7 @@ static MENU_UPDATE_FUNC(script_menu_update)
}
else
{
printf("[Lua] semaphore timeout: menu.update (%dms)\n", 100);
printf("[%s] semaphore timeout: menu.update (%dms)\n", lua_get_script_filename(L), 100);
}
}
}
......@@ -679,7 +679,7 @@ static void load_menu_entry(lua_State * L, struct script_menu_entry * script_ent
}
else
{
fprintf(stderr, "[Lua] invalid choice[%d]\n", choice_index);
fprintf(stderr, "[%s] invalid choice[%d]\n", lua_get_script_filename(L), choice_index);
menu_entry->choices[choice_index] = NULL;
choices_count = choice_index;
}
......@@ -729,7 +729,7 @@ static void load_menu_entry(lua_State * L, struct script_menu_entry * script_ent
}
else
{
fprintf(stderr, "[Lua] warning: could not create metatable submenu");
fprintf(stderr, "[%s] warning: could not create metatable submenu", lua_get_script_filename(L));
}
for (submenu_index = 0; submenu_index < submenu_count; submenu_index++)
......@@ -762,20 +762,20 @@ static void load_menu_entry(lua_State * L, struct script_menu_entry * script_ent
}
else
{
fprintf(stderr, "[Lua] warning: could not get metatable submenu");
fprintf(stderr, "[%s] warning: could not get metatable submenu", lua_get_script_filename(L));
}
lua_pop(L, 2);
}
else
{
fprintf(stderr, "[Lua] warning: could not get parent metatable");
fprintf(stderr, "[%s] warning: could not get parent metatable", lua_get_script_filename(L));
}
lua_pop(L, 1);//userdata
}
else
{
fprintf(stderr, "[Lua] invalid submenu[%d]\n", submenu_index);
fprintf(stderr, "[%s] invalid submenu[%d]\n", lua_get_script_filename(L), submenu_index);
}
lua_pop(L, 1);
}
......
......@@ -33,7 +33,7 @@ static void lua_run_task(struct lua_task_func * lua_task_func)
if (lua_get_cant_yield(L) == -1)
{
/* main task was unloaded? continuing would be use after free */
fprintf(stderr, "[Lua] will not start new tasks.\n");
fprintf(stderr, "[%s] will not start new tasks.\n", lua_get_script_filename(L));
goto skip;
}
......@@ -43,16 +43,16 @@ static void lua_run_task(struct lua_task_func * lua_task_func)
* it can't be unloaded while this task is running */
lua_set_cant_unload(L, 1, LUA_TASK_UNLOAD_MASK);
printf("[Lua] task starting.\n", lua_tostring(L, -1));
printf("[%s] task starting.\n", lua_get_script_filename(L));
if(docall(L, 0, 0))
{
fprintf(stderr, "[Lua] task error:\n%s\n", lua_tostring(L, -1));
fprintf(stderr, "[%s] task error:\n%s\n", lua_get_script_filename(L), lua_tostring(L, -1));
lua_save_last_error(L);
}
luaL_unref(L, LUA_REGISTRYINDEX, lua_task_func->function_ref);
printf("[Lua] task exiting.\n");
printf("[%s] task exiting.\n", lua_get_script_filename(L));
/* If all tasks started by the script are finished
* _before_ the main task ends, the script can be unloaded.
......@@ -72,7 +72,7 @@ static void lua_run_task(struct lua_task_func * lua_task_func)
}
else
{
printf("[Lua] semaphore error: run task\n");
printf("[%s] semaphore error: run task\n", lua_get_script_filename(L));
}
free(lua_task_func);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment