]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
indications: logging changes
authorMike Bradeen <mbradeen@sangoma.com>
Tue, 16 May 2023 18:43:37 +0000 (12:43 -0600)
committerGeorge Joseph <gtjoseph@users.noreply.github.com>
Mon, 5 Jun 2023 13:30:51 +0000 (07:30 -0600)
Increase verbosity to indicate failure due to missing country
and to specify default on CLI dump

Resolves: #89

main/indications.c

index d55c2475b437c3facfa47cb891e9f4ea0f6802c7..ccbf1b3bb43d075a689960755e5a321522337512 100644 (file)
@@ -411,11 +411,17 @@ static int ast_set_indication_country(const char *country)
 {
        struct ast_tone_zone *zone = NULL;
 
-       if (ast_strlen_zero(country) || !(zone = ast_get_indication_zone(country))) {
+       if (ast_strlen_zero(country)) {
+               ast_log(LOG_WARNING, "Failed to get indication zone, country not set\n");
+               return -1;
+       }
+
+       if (!(zone = ast_get_indication_zone(country))) {
+               ast_log(LOG_WARNING, "Failed to get indication zone: %s\n", country);
                return -1;
        }
 
-       ast_verb(3, "Setting default indication country to '%s'\n", country);
+       ast_log(LOG_NOTICE, "Setting default indication country to '%s'\n", country);
 
        ao2_lock(ast_tone_zones);
        if (default_tone_zone) {
@@ -836,6 +842,15 @@ static char *handle_cli_indication_show(struct ast_cli_entry *e, int cmd, struct
                        tz = ast_tone_zone_unref(tz);
                }
                ao2_iterator_destroy(&iter);
+
+               ao2_lock(ast_tone_zones);
+               if (default_tone_zone) {
+                       ast_cli(a->fd, "===========================\n");
+                       tz = ast_tone_zone_ref(default_tone_zone);
+                       ast_cli(a->fd, "Default tone zone: %s\n", tz->country);
+                       ast_tone_zone_unref(tz);
+               }
+               ao2_unlock(ast_tone_zones);
                return CLI_SUCCESS;
        }
 
@@ -1081,8 +1096,13 @@ static int load_indications(int reload)
 
        /* determine which country is the default */
        country = ast_variable_retrieve(cfg, "general", "country");
-       if (ast_strlen_zero(country) || ast_set_indication_country(country)) {
-               ast_log(LOG_WARNING, "Unable to set the default country (for indication tones)\n");
+       if (!ast_strlen_zero(country)) {
+               ast_log(LOG_NOTICE, "Default country for indication tones: %s\n", country);
+               if (ast_set_indication_country(country)) {
+                       ast_log(LOG_WARNING, "Unable to set the default country (for indication tones)\n");
+               }
+       } else {
+               ast_log(LOG_WARNING, "Missing default country (for indication tones)\n");
        }
 
        res = 0;