Commit e22df702ce5baa40b3ce34831b95c9565a1e9a6d
1 parent
5948c7b2
add logger get_WEB_plugin instead of print
Showing
2 changed files
with
59 additions
and
28 deletions
Show diff stats
net_services_protocols/logger_client.anubis
| @@ -62,8 +62,8 @@ public define One | @@ -62,8 +62,8 @@ public define One | ||
| 62 | forget(add_string(register_msg, "LOG_NAME", logger_name)); | 62 | forget(add_string(register_msg, "LOG_NAME", logger_name)); |
| 63 | forget(add_int32(register_msg, "FORMAT_SIZE", truncate_to_Word32(format_size))); | 63 | forget(add_int32(register_msg, "FORMAT_SIZE", truncate_to_Word32(format_size))); |
| 64 | forget(add_string(register_msg, "FILE_NAME", file_name)); | 64 | forget(add_string(register_msg, "FILE_NAME", file_name)); |
| 65 | - forget( add_int32(register_msg, "FILE_LEVEL", truncate_to_Word32(get_log_level_value(file_level)))); | ||
| 66 | - forget( add_int32(register_msg, "CONS_LEVEL", truncate_to_Word32(get_log_level_value(cons_level)))); | 65 | + forget( add_int32(register_msg, "FILE_LEVEL", truncate_to_Word32(to_Int(file_level)))); |
| 66 | + forget( add_int32(register_msg, "CONS_LEVEL", truncate_to_Word32(to_Int(cons_level)))); | ||
| 67 | local_net_logger("127.0.0.1", register_msg) | 67 | local_net_logger("127.0.0.1", register_msg) |
| 68 | . | 68 | . |
| 69 | 69 | ||
| @@ -90,7 +90,7 @@ public define One | @@ -90,7 +90,7 @@ public define One | ||
| 90 | String logger_name, | 90 | String logger_name, |
| 91 | String log_string | 91 | String log_string |
| 92 | )= | 92 | )= |
| 93 | - local_net_logger("127.0.0.1", create_log_msg(uid, logger_name, log_string, get_log_level_value(level))) | 93 | + local_net_logger("127.0.0.1", create_log_msg(uid, logger_name, log_string, to_Int(level))) |
| 94 | . | 94 | . |
| 95 | 95 | ||
| 96 | public define One | 96 | public define One |
web/plugin/plugin.anubis
| @@ -35,54 +35,85 @@ public type WEB_Plugin: | @@ -35,54 +35,85 @@ public type WEB_Plugin: | ||
| 35 | public define Maybe(WEB_Plugin) | 35 | public define Maybe(WEB_Plugin) |
| 36 | load_plugin | 36 | load_plugin |
| 37 | ( | 37 | ( |
| 38 | - String file_name | ||
| 39 | - ) | ||
| 40 | - = | 38 | + String file_name, |
| 39 | + (LogLevel, String) -> One logger | ||
| 40 | + )= | ||
| 41 | if (LoadAdm(WEB_Plugin))load_adm(file_name) is | 41 | if (LoadAdm(WEB_Plugin))load_adm(file_name) is |
| 42 | { | 42 | { |
| 43 | - file_not_found then print("File '"+file_name+"' not found.\n\n");failure, | ||
| 44 | - read_error then print("Error reading file '"+file_name+"'.\n\n");failure, | ||
| 45 | - timeout then print("Timeout when loading '"+file_name+"'.\n\n");failure, | ||
| 46 | - file_damaged then print("File '"+file_name+"' is damaged.\n\n");failure, | ||
| 47 | - bad_version(expected,found) then print("Secondary module '"+file_name+"' doesn't have the same\n"+ | 43 | + file_not_found then logger(logError, "File '"+file_name+"' not found.\n\n");failure, |
| 44 | + read_error then logger(logError, "Error reading file '"+file_name+"'.\n\n");failure, | ||
| 45 | + timeout then logger(logError, "Timeout when loading '"+file_name+"'.\n\n");failure, | ||
| 46 | + file_damaged then logger(logError, "File '"+file_name+"' is damaged.\n\n");failure, | ||
| 47 | + bad_version(expected,found) then logger(logError, "Secondary module '"+file_name+"' doesn't have the same\n"+ | ||
| 48 | " version ("+found+") as primary module ("+expected+").\n\n");failure, | 48 | " version ("+found+") as primary module ("+expected+").\n\n");failure, |
| 49 | - wrong_type(expected,found) then print("Secondary module '"+file_name+"' has different type as expected by primary module\n");failure, | ||
| 50 | - ok(ptah_plugin) then println("ptah plugin: APP ["+ptah_plugin.app_name+"] SPACE ["+ptah_plugin.space_name+"] version: "+ptah_plugin.version+" date: "+ptah_plugin.date+" loaded ");success(ptah_plugin) | ||
| 51 | - }. | ||
| 52 | - | 49 | + wrong_type(expected,found) then logger(logError, "Secondary module '"+file_name+"' has different type as expected by primary module\n");failure, |
| 50 | + ok(web_plugin) then logger(logInfo, "web plugin loaded: APP ["+web_plugin.app_name+"] SPACE ["+web_plugin.space_name+"] version: "+web_plugin.version+" date: "+web_plugin.date+" loaded ");success(web_plugin) | ||
| 51 | + } | ||
| 52 | +. | ||
| 53 | + | ||
| 54 | +public define Maybe(WEB_Plugin) | ||
| 55 | + load_plugin | ||
| 56 | + ( | ||
| 57 | + String file_name | ||
| 58 | + )= | ||
| 59 | + load_plugin(file_name, (LogLevel lvl, String string) |-> println(to_String(lvl)+" "+string)) | ||
| 60 | +. | ||
| 61 | + | ||
| 62 | + | ||
| 53 | public define List(WEB_Plugin) | 63 | public define List(WEB_Plugin) |
| 54 | all_plugins | 64 | all_plugins |
| 55 | ( | 65 | ( |
| 56 | - String directory, //directory where search the plugin file below | ||
| 57 | - String plugin_file_mask //mask for loading plugin like "my_app_plugin_*.adm" | ||
| 58 | - ) | ||
| 59 | - = | 66 | + String directory, //directory where search the plugin file below |
| 67 | + String plugin_file_mask, //mask for loading plugin like "my_app_plugin_*.adm" | ||
| 68 | + (LogLevel, String) -> One logger // | ||
| 69 | + )= | ||
| 60 | with files = directory_list(directory, plugin_file_mask), | 70 | with files = directory_list(directory, plugin_file_mask), |
| 61 | - map_select((String file_name) |-> load_plugin(directory+file_name), files) | ||
| 62 | - //merge_sort(all_list, migration_less) | 71 | + map_select( |
| 72 | + (String file_name) |-> | ||
| 73 | + load_plugin(directory+file_name, logger) | ||
| 74 | + , | ||
| 75 | + files | ||
| 76 | + ) | ||
| 77 | +. | ||
| 78 | + | ||
| 79 | +public define List(WEB_Plugin) | ||
| 80 | + all_plugins | ||
| 81 | + ( | ||
| 82 | + String directory, //directory where search the plugin file below | ||
| 83 | + String plugin_file_mask //mask for loading plugin like "my_app_plugin_*.adm" | ||
| 84 | + )= | ||
| 85 | + all_plugins(directory, plugin_file_mask, (LogLevel lvl, String string) |-> println(to_String(lvl)+" "+string)) | ||
| 63 | . | 86 | . |
| 64 | 87 | ||
| 65 | public define Maybe(WEB_Plugin) | 88 | public define Maybe(WEB_Plugin) |
| 66 | get_WEB_Plugin | 89 | get_WEB_Plugin |
| 67 | ( | 90 | ( |
| 68 | - List(WEB_Plugin) plugins, | ||
| 69 | - String _app, | ||
| 70 | - String _space | 91 | + List(WEB_Plugin) plugins, |
| 92 | + String _app, | ||
| 93 | + String _space, | ||
| 94 | + (LogLevel, String) -> One logger | ||
| 71 | )= | 95 | )= |
| 72 | if plugins is | 96 | if plugins is |
| 73 | { | 97 | { |
| 74 | - [] then println("get_WEB_Plugin for app ["+_app+"] space ["+_space+"] NOT FOUND");failure, | 98 | + [] then logger(logError, "get_WEB_Plugin for app ["+_app+"] space ["+_space+"] NOT FOUND");failure, |
| 75 | [h . t] then | 99 | [h . t] then |
| 76 | if h.app_name = _app & h.space_name = _space then | 100 | if h.app_name = _app & h.space_name = _space then |
| 77 | //println("get_WEB_Plugin for app ["+_app+"] space ["+_space+"] OK"); | 101 | //println("get_WEB_Plugin for app ["+_app+"] space ["+_space+"] OK"); |
| 78 | success(h) | 102 | success(h) |
| 79 | else | 103 | else |
| 80 | - get_WEB_Plugin(t, _app, _space) | 104 | + get_WEB_Plugin(t, _app, _space, logger) |
| 81 | } | 105 | } |
| 82 | . | 106 | . |
| 83 | 107 | ||
| 84 | - | ||
| 85 | - | 108 | +public define Maybe(WEB_Plugin) |
| 109 | + get_WEB_Plugin | ||
| 110 | + ( | ||
| 111 | + List(WEB_Plugin) plugins, | ||
| 112 | + String _app, | ||
| 113 | + String _space | ||
| 114 | + )= | ||
| 115 | + get_WEB_Plugin(plugins, _app, _space, (LogLevel lvl, String string) |-> println(to_String(lvl)+" "+string)) | ||
| 116 | +. | ||
| 86 | 117 | ||
| 87 | public define World_Left_Menu | 118 | public define World_Left_Menu |
| 88 | get_left_menu_from_plugins | 119 | get_left_menu_from_plugins |