log: improve initialization
authorZachary T Welch <zw@superlucidity.net>
Sat, 21 Nov 2009 00:36:32 +0000 (16:36 -0800)
committerZachary T Welch <zw@superlucidity.net>
Wed, 25 Nov 2009 18:29:06 +0000 (10:29 -0800)
Removes redundant assignment of start_ms from log_register_commands().
Eliminates command_context parameter and return value.
Adds Doxygen comment block for this API call.

src/helper/log.c
src/helper/log.h
src/openocd.c

index 3799fb322b91cf00a9120d51c27ea64170edc682..27fa8317aa6e0526037257affc9e14d1a3a8ddfa 100644 (file)
@@ -336,25 +336,20 @@ static struct command_registration log_command_handlers[] = {
 
 int log_register_commands(struct command_context *cmd_ctx)
 {
 
 int log_register_commands(struct command_context *cmd_ctx)
 {
-       start = timeval_ms();
-
        return register_commands(cmd_ctx, NULL, log_command_handlers);
 }
 
        return register_commands(cmd_ctx, NULL, log_command_handlers);
 }
 
-int log_init(struct command_context *cmd_ctx)
+void log_init(void)
 {
 {
-       /* set defaults for daemon configuration, if not set by cmdline or cfgfile */
+       /* set defaults for daemon configuration,
+        * if not set by cmdline or cfgfile */
        if (debug_level == -1)
                debug_level = LOG_LVL_INFO;
 
        if (log_output == NULL)
        if (debug_level == -1)
                debug_level = LOG_LVL_INFO;
 
        if (log_output == NULL)
-       {
                log_output = stderr;
                log_output = stderr;
-       }
 
        start = last_time = timeval_ms();
 
        start = last_time = timeval_ms();
-
-       return ERROR_OK;
 }
 
 int set_log_output(struct command_context *cmd_ctx, FILE *output)
 }
 
 int set_log_output(struct command_context *cmd_ctx, FILE *output)
index 6f7c24a80bb40f361381aaa7dfa6b97ae9822d4f..f2d19d16b13531152a7a8983a4cc02880e962bb3 100644 (file)
@@ -66,7 +66,10 @@ void log_printf_lf(enum log_levels level, const char *file, unsigned line,
        const char *function, const char *format, ...)
 __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6)));
 
        const char *function, const char *format, ...)
 __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6)));
 
-int log_init(struct command_context *cmd_ctx);
+/**
+ * Initialize logging module.  Call during program startup.
+ */
+void log_init(void);
 int set_log_output(struct command_context *cmd_ctx, FILE *output);
 
 int log_register_commands(struct command_context *cmd_ctx);
 int set_log_output(struct command_context *cmd_ctx, FILE *output);
 
 int log_register_commands(struct command_context *cmd_ctx);
index 1f29acdb5b3a1e825adfce053901db9d1fda38cf..629d50ae890bff1d9f73298d250c6d423a1fd524 100644 (file)
@@ -182,6 +182,9 @@ struct command_context *global_cmd_ctx;
 /* NB! this fn can be invoked outside this file for non PC hosted builds */
 struct command_context *setup_command_handler(void)
 {
 /* NB! this fn can be invoked outside this file for non PC hosted builds */
 struct command_context *setup_command_handler(void)
 {
+       log_init();
+       LOG_DEBUG("log_init: complete");
+
        struct command_context *cmd_ctx;
 
        global_cmd_ctx = cmd_ctx = command_init(openocd_startup_tcl);
        struct command_context *cmd_ctx;
 
        global_cmd_ctx = cmd_ctx = command_init(openocd_startup_tcl);
@@ -202,11 +205,7 @@ struct command_context *setup_command_handler(void)
        pld_register_commands(cmd_ctx);
        mflash_register_commands(cmd_ctx);
 
        pld_register_commands(cmd_ctx);
        mflash_register_commands(cmd_ctx);
 
-       if (log_init(cmd_ctx) != ERROR_OK)
-       {
-               exit(-1);
-       }
-       LOG_DEBUG("log init complete");
+       LOG_DEBUG("command registration: complete");
 
        LOG_OUTPUT(OPENOCD_VERSION "\n");
 
 
        LOG_OUTPUT(OPENOCD_VERSION "\n");
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)