commit a558ad8

default  ·  2023-04-13 07:59:00 +0000 UTC
parent e47cb4f
Changed mastoapi log levels.
1 files changed,  +14, -13
+14, -13
  1@@ -178,7 +178,7 @@ int oauth_get_handler(const xs_dict *req, const char *q_path,
  2     xs_dict *msg = xs_dict_get(req, "q_vars");
  3     xs *cmd      = xs_replace(q_path, "/oauth", "");
  4 
  5-    srv_debug(0, xs_fmt("oauth_get_handler %s", q_path));
  6+    srv_debug(1, xs_fmt("oauth_get_handler %s", q_path));
  7 
  8     if (strcmp(cmd, "/authorize") == 0) {
  9         const char *cid   = xs_dict_get(msg, "client_id");
 10@@ -230,7 +230,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
 11     xs_dict *msg = xs_dict_get(req, "p_vars");
 12     xs *cmd      = xs_replace(q_path, "/oauth", "");
 13 
 14-    srv_debug(0, xs_fmt("oauth_post_handler %s", q_path));
 15+    srv_debug(1, xs_fmt("oauth_post_handler %s", q_path));
 16 
 17     if (strcmp(cmd, "/x-snac-login") == 0) {
 18         const char *login  = xs_dict_get(msg, "login");
 19@@ -266,7 +266,8 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
 20                         *body = xs_str_cat(*body, state);
 21                     }
 22 
 23-                    srv_debug(0, xs_fmt("oauth x-snac-login: success, redirect to %s", *body));
 24+                    srv_log(xs_fmt("oauth x-snac-login: '%s' success, redirect to %s",
 25+                                   login, *body));
 26 
 27                     /* assign the login to the app */
 28                     xs *app = app_get(cid);
 29@@ -280,15 +281,15 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
 30                         srv_log(xs_fmt("oauth x-snac-login: error getting app %s", cid));
 31                 }
 32                 else
 33-                    srv_debug(0, xs_fmt("oauth x-snac-login: login '%s' incorrect", login));
 34+                    srv_debug(1, xs_fmt("oauth x-snac-login: login '%s' incorrect", login));
 35 
 36                 user_free(&snac);
 37             }
 38             else
 39-                srv_debug(0, xs_fmt("oauth x-snac-login: bad user '%s'", login));
 40+                srv_debug(1, xs_fmt("oauth x-snac-login: bad user '%s'", login));
 41         }
 42         else
 43-            srv_debug(0, xs_fmt("oauth x-snac-login: invalid or unset arguments"));
 44+            srv_debug(1, xs_fmt("oauth x-snac-login: invalid or unset arguments"));
 45     }
 46     else
 47     if (strcmp(cmd, "/token") == 0) {
 48@@ -378,7 +379,7 @@ int oauth_post_handler(const xs_dict *req, const char *q_path,
 49             *ctype = "application/json";
 50 
 51             if (token == NULL || strcmp(csec, xs_dict_get(token, "client_secret")) != 0) {
 52-                srv_debug(0, xs_fmt("oauth revoke: bad secret for token %s", tokid));
 53+                srv_debug(1, xs_fmt("oauth revoke: bad secret for token %s", tokid));
 54                 status = 403;
 55             }
 56             else {
 57@@ -614,7 +615,7 @@ int process_auth_token(snac *snac, const xs_dict *req)
 58 
 59             if (!xs_is_null(uid) && user_open(snac, uid)) {
 60                 logged_in = 1;
 61-                srv_debug(0, xs_fmt("mastoapi auth: valid token for user %s", uid));
 62+                srv_debug(1, xs_fmt("mastoapi auth: valid token for user %s", uid));
 63             }
 64             else
 65                 srv_log(xs_fmt("mastoapi auth: corrupted token %s", tokid));
 66@@ -633,7 +634,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
 67     if (!xs_startswith(q_path, "/api/v1/"))
 68         return 0;
 69 
 70-    srv_debug(0, xs_fmt("mastoapi_get_handler %s", q_path));
 71+    srv_debug(1, xs_fmt("mastoapi_get_handler %s", q_path));
 72 /*    {
 73         xs *j = xs_json_dumps_pp(req, 4);
 74         printf("mastoapi get:\n%s\n", j);
 75@@ -825,12 +826,12 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
 76             {
 77                 xs *j = xs_json_loads(*body);
 78                 if (j == NULL) {
 79-                    srv_debug(0, xs_fmt("mastoapi timeline: bad JSON"));
 80+                    srv_log(xs_fmt("mastoapi timeline: bad JSON"));
 81                     srv_archive_error("mastoapi_timeline", "bad JSON", req, *body);
 82                 }
 83             }
 84 
 85-            srv_debug(0, xs_fmt("mastoapi timeline: returned %d entries", xs_list_len(out)));
 86+            srv_debug(2, xs_fmt("mastoapi timeline: returned %d entries", xs_list_len(out)));
 87         }
 88         else {
 89             status = 401; // unauthorized
 90@@ -1030,7 +1031,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
 91                 }
 92             }
 93             else
 94-                srv_debug(0, xs_fmt("mastoapi status: bad id %s", id));
 95+                srv_debug(1, xs_fmt("mastoapi status: bad id %s", id));
 96 
 97             if (out != NULL) {
 98                 *body  = xs_json_dumps_pp(out, 4);
 99@@ -1061,7 +1062,7 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
100     if (!xs_startswith(q_path, "/api/v1/"))
101         return 0;
102 
103-    srv_debug(0, xs_fmt("mastoapi_post_handler %s", q_path));
104+    srv_debug(1, xs_fmt("mastoapi_post_handler %s", q_path));
105 /*    {
106         xs *j = xs_json_dumps_pp(req, 4);
107         printf("mastoapi post:\n%s\n", j);