Changeset eab3d04 in mainline
- Timestamp:
- 2012-08-16T11:36:54Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 494f417
- Parents:
- 1c67b41
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/logset/main.c
r1c67b41 reab3d04 47 47 } 48 48 49 log_level_t new_default_level = (log_level_t) strtol(argv[1], NULL, 0); 49 log_level_t new_default_level; 50 int rc = log_level_from_str(argv[1], &new_default_level); 51 if (rc != EOK) { 52 fprintf(stderr, "Unrecognised log level '%s': %s.\n", 53 argv[1], str_error(rc)); 54 } 50 55 51 intrc = logctl_set_default_level(new_default_level);56 rc = logctl_set_default_level(new_default_level); 52 57 53 58 if (rc != EOK) { -
uspace/lib/c/generic/io/log.c
r1c67b41 reab3d04 52 52 "note", 53 53 "debug", 54 "debug2" 54 "debug2", 55 NULL 55 56 }; 56 57 … … 179 180 } 180 181 182 int log_level_from_str(const char *name, log_level_t *level_out) 183 { 184 log_level_t level = LVL_FATAL; 185 186 while (log_level_names[level] != NULL) { 187 if (str_cmp(name, log_level_names[level]) == 0) { 188 if (level_out != NULL) 189 *level_out = level; 190 return EOK; 191 } 192 level++; 193 } 194 195 /* Maybe user specified number directly. */ 196 char *end_ptr; 197 int level_int = strtol(name, &end_ptr, 0); 198 if ((end_ptr == name) || (str_length(end_ptr) != 0)) 199 return EINVAL; 200 if (level_int < 0) 201 return ERANGE; 202 if (level_int >= (int) LVL_LIMIT) 203 return ERANGE; 204 205 if (level_out != NULL) 206 *level_out = (log_level_t) level_int; 207 208 return EOK; 209 } 210 181 211 /** Initialize the logging system. 182 212 * -
uspace/lib/c/generic/io/logctl.c
r1c67b41 reab3d04 84 84 return EINVAL; 85 85 86 char level_str[ 10];87 str_cpy(level_str, 10, (const char *) argument);86 char level_str[20]; 87 str_cpy(level_str, 20, (const char *) argument); 88 88 89 int level_int = strtol(level_str, NULL, 0); 90 91 log_level_t boot_level = (log_level_t) level_int; 92 if (boot_level >= LVL_LIMIT) 93 return EINVAL; 89 log_level_t boot_level; 90 int rc = log_level_from_str(level_str, &boot_level); 91 if (rc != EOK) 92 return rc; 94 93 95 94 if (level != NULL) -
uspace/lib/c/include/io/log.h
r1c67b41 reab3d04 51 51 52 52 extern const char *log_level_str(log_level_t); 53 extern int log_level_from_str(const char *, log_level_t *); 53 54 54 55 extern bool __log_shall_record(log_level_t);
Note:
See TracChangeset
for help on using the changeset viewer.