Changeset 80d8885 in mainline
- Timestamp:
- 2012-08-16T15:08:19Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dc5aa568
- Parents:
- 32b26cf7
- Location:
- uspace
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/logset/main.c
r32b26cf7 r80d8885 55 55 fprintf(stderr, " %s <default-logging-level>\n", progname); 56 56 fprintf(stderr, " %s <namespace> <logging-level>\n", progname); 57 fprintf(stderr, " %s <namespace> <context> <logging-level>\n", progname); 57 58 } 58 59 … … 78 79 return 2; 79 80 } 81 } else if (argc == 4) { 82 log_level_t new_level = parse_log_level_or_die(argv[3]); 83 const char *namespace = argv[1]; 84 const char *context = argv[2]; 85 int rc = logctl_set_context_level(namespace, context, new_level); 86 if (rc != EOK) { 87 fprintf(stderr, "Failed to change logging level: %s.\n", 88 str_error(rc)); 89 return 2; 90 } 80 91 } else { 81 92 usage(argv[0]); -
uspace/lib/c/generic/io/logctl.c
r32b26cf7 r80d8885 105 105 } 106 106 107 int logctl_set_context_level(const char *namespace, const char *context, log_level_t new_level) 108 { 109 async_exch_t *exchange = NULL; 110 int rc = start_logger_exchange(&exchange); 111 if (rc != EOK) 112 return rc; 113 114 aid_t reg_msg = async_send_1(exchange, LOGGER_CTL_SET_CONTEXT_LEVEL, 115 new_level, NULL); 116 rc = async_data_write_start(exchange, namespace, str_size(namespace)); 117 int rc2 = async_data_write_start(exchange, context, str_size(context)); 118 sysarg_t reg_msg_rc; 119 async_wait_for(reg_msg, ®_msg_rc); 120 121 async_exchange_end(exchange); 122 123 if (rc != EOK) 124 return rc; 125 126 if (rc2 != EOK) 127 return rc2; 128 129 return (int) reg_msg_rc; 130 } 131 132 107 133 int logctl_get_boot_level(log_level_t *level) 108 134 { -
uspace/lib/c/include/io/logctl.h
r32b26cf7 r80d8885 38 38 extern int logctl_set_default_level(log_level_t); 39 39 extern int logctl_set_namespace_level(const char *, log_level_t); 40 extern int logctl_set_context_level(const char *, const char *, log_level_t); 40 41 extern int logctl_get_boot_level(log_level_t *); 41 42 -
uspace/lib/c/include/ipc/logger.h
r32b26cf7 r80d8885 39 39 LOGGER_CTL_GET_DEFAULT_LEVEL = IPC_FIRST_USER_METHOD, 40 40 LOGGER_CTL_SET_DEFAULT_LEVEL, 41 LOGGER_CTL_SET_NAMESPACE_LEVEL 41 LOGGER_CTL_SET_NAMESPACE_LEVEL, 42 LOGGER_CTL_SET_CONTEXT_LEVEL 42 43 } logger_control_request_t; 43 44 -
uspace/srv/logger/logger.h
r32b26cf7 r80d8885 61 61 62 62 int namespace_create_context(logging_namespace_t *, const char *); 63 int namespace_change_context_level(logging_namespace_t *, const char *, log_level_t); 63 64 64 65 log_level_t get_default_logging_level(void); -
uspace/srv/logger/main.c
r32b26cf7 r80d8885 67 67 } 68 68 69 static int handle_context_level_change(sysarg_t new_level) 70 { 71 void *namespace_name; 72 int rc = async_data_write_accept(&namespace_name, true, 0, 0, 0, NULL); 73 if (rc != EOK) { 74 return rc; 75 } 76 77 logging_namespace_t *namespace = namespace_writer_attach((const char *) namespace_name); 78 free(namespace_name); 79 if (namespace == NULL) 80 return ENOENT; 81 82 void *context_name; 83 rc = async_data_write_accept(&context_name, true, 0, 0, 0, NULL); 84 if (rc != EOK) { 85 namespace_writer_detach(namespace); 86 return rc; 87 } 88 89 rc = namespace_change_context_level(namespace, context_name, new_level); 90 free(context_name); 91 namespace_writer_detach(namespace); 92 93 return rc; 94 } 95 69 96 static void connection_handler_control(void) 70 97 { … … 90 117 case LOGGER_CTL_SET_NAMESPACE_LEVEL: 91 118 rc = handle_namespace_level_change(IPC_GET_ARG1(call)); 119 async_answer_0(callid, rc); 120 break; 121 case LOGGER_CTL_SET_CONTEXT_LEVEL: 122 rc = handle_context_level_change(IPC_GET_ARG1(call)); 92 123 async_answer_0(callid, rc); 93 124 break; -
uspace/srv/logger/namespace.c
r32b26cf7 r80d8885 71 71 if (context >= namespace->context_count) { 72 72 fibril_mutex_unlock(&namespace->guard); 73 fprintf(stderr, "Invalid context!\n"); 73 74 return LVL_FATAL; 74 75 } … … 265 266 } 266 267 268 int namespace_change_context_level(logging_namespace_t *namespace, const char *context, log_level_t new_level) 269 { 270 if (new_level >= LVL_LIMIT) 271 return ERANGE; 272 273 int rc; 274 fibril_mutex_lock(&namespace->guard); 275 for (size_t i = 0; i < namespace->context_count; i++) { 276 if (str_cmp(namespace->context[i].name, context) == 0) { 277 namespace->context[i].level = new_level; 278 rc = EOK; 279 fibril_condvar_broadcast(&namespace->level_changed_cv); 280 goto leave; 281 } 282 } 283 rc = ENOENT; 284 285 leave: 286 fibril_mutex_unlock(&namespace->guard); 287 return rc; 288 } 289 267 290 void namespace_wait_for_reader_change(logging_namespace_t *namespace, bool *has_reader_now) 268 291 { 269 292 fibril_mutex_lock(&namespace->guard); 270 log_level_t previous_level = namespace->level; 271 while (previous_level == namespace->level) { 272 fibril_condvar_wait(&namespace->level_changed_cv, &namespace->guard); 273 } 293 // FIXME: properly watch for state change 294 fibril_condvar_wait(&namespace->level_changed_cv, &namespace->guard); 274 295 *has_reader_now = true; 275 296 fibril_mutex_unlock(&namespace->guard);
Note:
See TracChangeset
for help on using the changeset viewer.