commit d1ed689
uint
·
2026-01-28 02:58:18 +0000 UTC
parent 11cd826
capitalise first letter of logs
6 files changed,
+44,
-44
+7,
-7
1@@ -162,20 +162,20 @@ void config_load(void)
2 goto log;
3 }
4
5- LOG(true, "CONF", "unable to load configuration... using defaults", e);
6+ LOG(true, "CONF", "Unable to load configuration... using defaults", e);
7 return;
8
9 log:
10- LOG(true, "CONF", "Config File: %s", path);
11- LOG(true, "CONF", "Media Directory: %s", media_dir);
12- LOG(true, "CONF", "Server Address: %s", server_addr);
13+ LOG(true, "CONF", "Config File %s", path);
14+ LOG(true, "CONF", "Media Directory %s", media_dir);
15+ LOG(true, "CONF", "Server Address %s", server_addr);
16
17 char port[8];
18 snprintf(port, sizeof(port), "%d", server_port);
19- LOG(true, "CONF", "Server Port: %s", port);
20+ LOG(true, "CONF", "Server Port %s", port);
21
22- LOG(true, "CONF", "Verbose Logging: %s", (verbose_log) ? "true" : "false");
23- LOG(true, "CONF", "CORS origins: %s", cors_origin);
24+ LOG(true, "CONF", "Verbose Logging %s", (verbose_log) ? "true" : "false");
25+ LOG(true, "CONF", "CORS origins %s", cors_origin);
26
27 return;
28 }
+20,
-20
1@@ -525,16 +525,16 @@ static int stream_file(int c, const struct item* it, const char* hdr, int head_o
2
3 /* build absolute path */
4 if (join_path(full, sizeof(full), media_dir, it->path) < 0) {
5- LOG(verbose_log, "HTTP", "path too long");
6- reply_text(c, hdr, HTTP_500, "server error\n");
7+ LOG(verbose_log, "HTTP", "Path too long");
8+ reply_text(c, hdr, HTTP_500, "Server error\n");
9 return -1;
10 }
11
12 /* open file */
13 int fd = open(full, O_RDONLY);
14 if (fd < 0) {
15- LOG(verbose_log, "HTTP", "open failed: %s", it->path);
16- reply_text(c, hdr, HTTP_404, "not found\n");
17+ LOG(verbose_log, "HTTP", "Open failed: %s", it->path);
18+ reply_text(c, hdr, HTTP_404, "Not found\n");
19 return 0;
20 }
21
22@@ -542,14 +542,14 @@ static int stream_file(int c, const struct item* it, const char* hdr, int head_o
23 struct stat st;
24 if (fstat(fd, &st) < 0) {
25 close(fd);
26- reply_text(c, hdr, HTTP_500, "server error\n");
27+ reply_text(c, hdr, HTTP_500, "Server error\n");
28 return -1;
29 }
30
31 /* reject non-regular files */
32 if (!S_ISREG(st.st_mode)) {
33 close(fd);
34- reply_text(c, hdr, HTTP_404, "not found\n");
35+ reply_text(c, hdr, HTTP_404, "Not found\n");
36 return 0;
37 }
38
39@@ -634,9 +634,9 @@ static int stream_file(int c, const struct item* it, const char* hdr, int head_o
40 close(fd);
41
42 if (partial == RANGE_OK)
43- LOG(verbose_log, "HTTP", "header %s [%zu-%zu/%zu]", it->path, start, end, total);
44+ LOG(verbose_log, "HTTP", "Header %s [%zu-%zu/%zu]", it->path, start, end, total);
45 else
46- LOG(verbose_log, "HTTP", "header %s (%zu bytes)", it->path, total);
47+ LOG(verbose_log, "HTTP", "Header %s (%zu bytes)", it->path, total);
48
49 return 0;
50 }
51@@ -669,9 +669,9 @@ static int stream_file(int c, const struct item* it, const char* hdr, int head_o
52 close(fd);
53
54 if (partial == RANGE_OK)
55- LOG(verbose_log, "HTTP", "streamed %s [%zu-%zu/%zu]", it->path, start, end, total);
56+ LOG(verbose_log, "HTTP", "Streamed %s [%zu-%zu/%zu]", it->path, start, end, total);
57 else
58- LOG(verbose_log, "HTTP", "streamed %s (%zu bytes)", it->path, total);
59+ LOG(verbose_log, "HTTP", "Streamed %s (%zu bytes)", it->path, total);
60
61 return 0;
62 }
63@@ -691,7 +691,7 @@ int http_handle(int c)
64 reply_text(c, hdr, HTTP_400, "bad request\n");
65 return -1;
66 }
67- LOG(verbose_log, "HTTP", "request: %s %s", method, path);
68+ LOG(verbose_log, "HTTP", "Request: %s %s", method, path);
69
70 int head_only = 0;
71 if (strcmp(method, "GET") == 0) {
72@@ -705,13 +705,13 @@ int http_handle(int c)
73 return 0;
74 }
75 else {
76- LOG(verbose_log, "HTTP", "method not allowed: %s", method);
77+ LOG(verbose_log, "HTTP", "Method not allowed: %s", method);
78 reply_text(c, hdr, HTTP_405, "method not allowed\n");
79 return 0;
80 }
81
82 if (strcmp(path, "/ping") == 0) {
83- LOG(verbose_log, "HTTP", "route /ping");
84+ LOG(verbose_log, "HTTP", "Route /ping");
85 reply_text(c, hdr, HTTP_200, "ok\n");
86 return 0;
87 }
88@@ -725,7 +725,7 @@ int http_handle(int c)
89 }
90
91 if (strcmp(path, "/library") == 0) {
92- LOG(verbose_log, "HTTP", "route /library");
93+ LOG(verbose_log, "HTTP", "Route /library");
94 struct json j;
95 struct library view;
96 memset(&view, 0, sizeof(view));
97@@ -754,11 +754,11 @@ int http_handle(int c)
98 if (u)
99 free(view.items);
100
101- LOG(verbose_log, "JSON", "encode failed");
102+ LOG(verbose_log, "JSON", "Encode failed");
103 reply_text(c, hdr, HTTP_500, "json failed\n");
104 return -1;
105 }
106- LOG(verbose_log, "JSON", "encoded %zu bytes", j.len);
107+ LOG(verbose_log, "JSON", "Encoded %zu bytes", j.len);
108
109 reply_json(c, hdr, HTTP_200, j.buf, j.len, !head_only);
110 json_free(&j);
111@@ -770,7 +770,7 @@ int http_handle(int c)
112 }
113
114 if (strncmp(path, "/stream/", 8) == 0) {
115- LOG(verbose_log, "HTTP", "route /stream");
116+ LOG(verbose_log, "HTTP", "Route /stream");
117
118 uint64_t id;
119 if (parse_hex64(path + 8, &id) < 0) {
120@@ -792,7 +792,7 @@ int http_handle(int c)
121 }
122
123 if (strncmp(path, "/meta/", 6) == 0) {
124- LOG(verbose_log, "HTTP", "route /meta");
125+ LOG(verbose_log, "HTTP", "Route /meta");
126
127 uint64_t id;
128 if (parse_hex64(path + 6, &id) < 0) {
129@@ -831,7 +831,7 @@ int http_handle(int c)
130 }
131
132 if (strcmp(path, "/queue") == 0) {
133- LOG(verbose_log, "HTTP", "route /queue");
134+ LOG(verbose_log, "HTTP", "Route /queue");
135
136 if (queue_write(c, hdr, head_only, u) < 0) {
137 reply_text(c, hdr, HTTP_500, "server error\n");
138@@ -841,7 +841,7 @@ int http_handle(int c)
139 return 0;
140 }
141
142- LOG(verbose_log, "HTTP", "route not found: %s", path);
143+ LOG(verbose_log, "HTTP", "Route not found: %s", path);
144 reply_text(c, hdr, HTTP_404, "not found\n");
145
146 return 0;
+1,
-1
1@@ -25,7 +25,7 @@ static int json_grow(struct json* j, size_t need)
2
3 char* nb = realloc(j->buf, ncap);
4 if (!nb) {
5- LOG(verbose_log, "JSON", "out of memory");
6+ LOG(verbose_log, "JSON", "Out of memory");
7 return -1;
8 }
9
+3,
-3
1@@ -47,7 +47,7 @@ void run(void)
2 continue;
3 continue;
4 }
5- LOG(verbose_log, "CORE", "connection accepted");
6+ LOG(verbose_log, "CORE", "Connection accepted");
7
8 pid_t pid = fork();
9 if (pid < 0) {
10@@ -98,13 +98,13 @@ void setup(void)
11
12 if (scan_library(&lib, media_dir) < 0)
13 die("scan_library", EXIT_FAILURE);
14- LOG(verbose_log, "SCAN", "cached %zu items", lib.len);
15+ LOG(verbose_log, "SCAN", "Cached %zu items", lib.len);
16
17 ret = listen(sock, LISTEN_BACKLOG);
18 if (ret < 0)
19 die("listen", EXIT_FAILURE);
20
21- LOG(verbose_log, "CORE", "listening on %s:%d", server_addr, server_port);
22+ LOG(verbose_log, "CORE", "Listening on %s:%d", server_addr, server_port);
23 }
24
25 int main(void)
+1,
-1
1@@ -36,7 +36,7 @@ static int library_push(struct library* l, const char* rel)
2 size_t ncap = l->cap ? (l->cap * 2) : 64;
3 struct item* ni = realloc(l->items, ncap * sizeof(*ni));
4 if (!ni) {
5- LOG(verbose_log, "SCAN", "out of memory");
6+ LOG(verbose_log, "SCAN", "Out of memory");
7 return -1;
8 }
9 l->items = ni;
+12,
-12
1@@ -152,11 +152,11 @@ bool user_allows_path(const struct user* u, const char* relpath)
2 int users_add_allow(const char* prefix)
3 {
4 if (users.len == 0 || !prefix) {
5- LOG(true, "AUTH", "users_add_allow: missing user or prefix");
6+ LOG(true, "AUTH", "Missing user or prefix");
7 return -1;
8 }
9
10- LOG(verbose_log, "AUTH", "allow for %s: %s", users.v[users.len - 1].name, prefix);
11+ LOG(verbose_log, "AUTH", "Allow for %s: %s", users.v[users.len - 1].name, prefix);
12
13 return allow_push(&users.v[users.len - 1], prefix);
14 }
15@@ -168,7 +168,7 @@ const struct user* users_auth_from_hdr(const char* hdr)
16
17 char auth[512];
18 if (hdr_get_value(auth, hdr, "authorization") < 0) {
19- LOG(true, "AUTH", "no Authorization header");
20+ LOG(true, "AUTH", "No Authorization header");
21 return NULL;
22 }
23
24@@ -209,26 +209,26 @@ const struct user* users_auth_from_hdr(const char* hdr)
25
26 const struct user* u = find_user(user);
27 if (!u) {
28- LOG(true, "AUTH", "auth failed: unknown user '%s'", user);
29+ LOG(true, "AUTH", "Auth failed: unknown user '%s'", user);
30 return NULL;
31 }
32
33 /* empty password -> passwordless account */
34 if (u->pass[0] == '\0') {
35 if (pass[0] == '\0') {
36- LOG(true, "AUTH", "auth ok: %s (passwordless)", user);
37+ LOG(true, "AUTH", "Auth ok: %s (passwordless)", user);
38 return u;
39 }
40- LOG(true, "AUTH", "auth failed: %s (passwordless) but pass given", user);
41+ LOG(true, "AUTH", "Auth failed: %s (passwordless but pass given)", user);
42 return NULL;
43 }
44
45 if (!ct_equal(u->pass, pass)) {
46- LOG(true, "AUTH", "auth failed: bad password for %s", user);
47+ LOG(true, "AUTH", "Auth failed: bad password for %s", user);
48 return NULL;
49 }
50
51- LOG(verbose_log, "AUTH", "auth ok: %s", user);
52+ LOG(verbose_log, "AUTH", "Auth ok: %s", user);
53 return u;
54 }
55
56@@ -253,7 +253,7 @@ void users_free(void)
57 int users_push(const char* name)
58 {
59 if (!name || name[0] == '\0') {
60- LOG(true, "AUTH", "empty username");
61+ LOG(true, "AUTH", "Empty username");
62 return -1;
63 }
64
65@@ -271,7 +271,7 @@ int users_push(const char* name)
66 memset(&users.v[users.len], 0, sizeof(users.v[users.len]));
67 snprintf(users.v[users.len].name, sizeof(users.v[users.len].name), "%s", name);
68
69- LOG(verbose_log, "AUTH", "user added: %s", users.v[users.len].name);
70+ LOG(verbose_log, "AUTH", "User added: %s", users.v[users.len].name);
71
72 users.len++;
73 return 0;
74@@ -280,7 +280,7 @@ int users_push(const char* name)
75 int users_set_pass(const char* pass)
76 {
77 if (users.len == 0) {
78- LOG(true, "AUTH", "no user yet");
79+ LOG(true, "AUTH", "No user yet");
80 return -1;
81 }
82
83@@ -291,7 +291,7 @@ int users_set_pass(const char* pass)
84 snprintf(users.v[users.len - 1].pass, sizeof(users.v[users.len - 1].pass), "%s", pass);
85
86 LOG(
87- verbose_log, "AUTH", "pass set for user: %s (%s)",
88+ verbose_log, "AUTH", "Pass set for user: %s (%s)",
89 users.v[users.len - 1].name, (pass[0] == '\0') ? "empty" : "non-empty"
90 );
91 return 0;