summaryrefslogtreecommitdiff
path: root/src/cache/handlers
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-03-18 10:56:12 -0400
committerAndrew Opalach <andrew@akon.city> 2025-03-18 10:56:12 -0400
commit191d98d306d48ba36d5a5a2eb3583b805a03b2c3 (patch)
tree3c917adaf66e6d348046beee510a9a1ed1dc1a41 /src/cache/handlers
parentf0accac221a53633380f15b4953ca4f4fdfbeca7 (diff)
downloadcamu-191d98d306d48ba36d5a5a2eb3583b805a03b2c3.tar.gz
camu-191d98d306d48ba36d5a5a2eb3583b805a03b2c3.tar.bz2
camu-191d98d306d48ba36d5a5a2eb3583b805a03b2c3.zip
Cleanup
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/cache/handlers')
-rw-r--r--src/cache/handlers/cdio.c23
-rw-r--r--src/cache/handlers/http.c11
2 files changed, 18 insertions, 16 deletions
diff --git a/src/cache/handlers/cdio.c b/src/cache/handlers/cdio.c
index 1b4c44b..3eae813 100644
--- a/src/cache/handlers/cdio.c
+++ b/src/cache/handlers/cdio.c
@@ -1,3 +1,4 @@
+#define AL_LOG_SECTION "cache_cdio"
#include <al/log.h>
#include "../backings/file.h"
@@ -15,13 +16,13 @@ static void cdio_log_messages(struct cch_handler_cdio *cdio)
{
char *error_messages = cdio_cddap_errors(cdio->drive);
if (error_messages) {
- al_log_error("cdio", "\n%s", error_messages);
+ error("\n%s", error_messages);
cdio_cddap_free_messages(error_messages);
}
char *messages = cdio_cddap_messages(cdio->drive);
if (messages) {
- al_log_info("cdio", "\n%s", messages);
+ info("\n%s", messages);
cdio_cddap_free_messages(messages);
}
}
@@ -50,18 +51,18 @@ static nn_thread_result NNWT_THREADCALL cd_read_thread(void *userdata)
size_t size;
u8 *ptr = cdio->backing->get_ptr(cdio->backing, pointer, &size);
if (size < BYTES_PER_STEP) {
- al_log_error("cdio", "Tried to write over expected size during normal operation.");
+ error("Tried to write over expected size during normal operation.");
cdio->backing->unlock(cdio->backing);
break;
}
if (ret == SECTORS_PER_STEP) {
al_memcpy(ptr, nn_buffer_get_ptr(&cdio->buffer, 0), BYTES_PER_STEP);
} else if (ret == -10) {
- al_log_error("cdio", "I/O error, skipping sector.");
+ error("I/O error, skipping sector.");
al_memset(ptr, 0, BYTES_PER_STEP);
ret = SECTORS_PER_STEP;
} else if (ret < 0) {
- al_log_error("cdio", "Fatal error (%d).", ret);
+ error("Fatal error (%d).", ret);
cdio->backing->unlock(cdio->backing);
break;
}
@@ -70,13 +71,13 @@ static nn_thread_result NNWT_THREADCALL cd_read_thread(void *userdata)
cdio->backing->unlock(cdio->backing);
cch_threaded_waits_evaluate(&cdio->waits, cdio->backing);
if (ret < SECTORS_PER_STEP || cdio->sector > cdio->end) {
- al_log_debug("cdio", "Normal CD EOF.");
+ debug("Normal CD EOF.");
break;
}
}
if (cdio->sector <= cdio->end) {
- al_log_warn("cdio", "Disc read cut short (sectors: %zd, end: %zd).", cdio->sector, cdio->end);
+ warn("Disc read cut short (sectors: %zd, end: %zd).", cdio->sector, cdio->end);
// We didn't read the full disc, disable waiters.
cch_threaded_waits_disable_all(&cdio->waits);
}
@@ -134,7 +135,7 @@ static bool open_cd_drive(struct cch_handler_cdio *cdio)
cdio_handle = cdio_open(*cd_drives, DRIVER_UNKNOWN);
drive = cdio_cddap_identify_cdio(cdio_handle, CDDA_MESSAGE_LOGIT, NULL);
} else {
- al_log_error("cdio", "No compatible disc found.");
+ error("No compatible disc found.");
return false;
}
cdio_free_device_list(cd_drives);
@@ -143,19 +144,19 @@ static bool open_cd_drive(struct cch_handler_cdio *cdio)
s32 ret = cdio_cddap_open(drive);
if (ret != 0) {
- al_log_error("cdio", "Unable to open disc (%d).", ret);
+ error("Unable to open disc (%d).", ret);
return false;
}
ret = cdio_cddap_speed_set(drive, 4);
if (ret != 0) {
- al_log_warn("cdio", "Failed to set drive speed (%d).", ret);
+ warn("Failed to set drive speed (%d).", ret);
}
track_t tracks = cdio_cddap_tracks(drive);
track_t first_track = cdio_get_first_track_num(drive->p_cdio);
track_t last_track = cdio_get_last_track_num(drive->p_cdio);
- al_log_info("cdio", "CD with %d tracks loaded (%d-%d).", tracks, first_track, last_track);
+ info("CD with %d tracks loaded (%d-%d).", tracks, first_track, last_track);
al_array_reserve(cdio->handler.entry->chapters, tracks);
lsn_t start = cdio_cddap_disc_firstsector(drive);
diff --git a/src/cache/handlers/http.c b/src/cache/handlers/http.c
index 1856014..d5c06dc 100644
--- a/src/cache/handlers/http.c
+++ b/src/cache/handlers/http.c
@@ -1,3 +1,4 @@
+#define AL_LOG_SECTION "cache_http"
#include <al/log.h>
#include "../backings/memory.h"
@@ -35,23 +36,23 @@ static void http_callback(void *userdata, u8 op, u8 *buf, void *opaque)
}
case NNWT_HTTP_RESPONSE_CODE: {
long response_code = *(long *)opaque;
- al_log_debug("cache_handler_http", "HTTP %ld.", response_code);
+ debug("HTTP %ld.", response_code);
break;
}
case NNWT_HTTP_CONTENT_LENGTH: {
curl_off_t length = *(curl_off_t *)opaque;
- al_log_debug("cache_handler_http", "Content-Length: %"CURL_FORMAT_CURL_OFF_T".", length);
+ debug("Content-Length: %"CURL_FORMAT_CURL_OFF_T".", length);
cch_entry_set_size(http->handler.entry, length);
cch_threaded_waits_signal_any(&http->waits);
break;
}
case NNWT_HTTP_REDIRECT: {
long response_code = *(long *)opaque;
- al_log_debug("cache_handler_http", "Redirect %ld.", response_code);
+ debug("Redirect %ld.", response_code);
break;
}
case NNWT_HTTP_FINISHED:
- al_log_debug("cache_handler_http", "Transfer finished.");
+ debug("Transfer finished.");
break;
case NNWT_HTTP_ERROR:
cch_threaded_waits_disable_all(&http->waits);
@@ -71,7 +72,7 @@ static void handler_http_maybe_spawn_worker(struct cch_handler *handler, size_t
nn_http_set_url(request, &http->url);
nn_http_set_user_agent(request, &USER_AGENT);
nn_http_request_stream(request, NNWT_HTTP_GET, http->loop, http_callback, http);
- al_log_debug("cache_handler_http", "Spawning worker for %.*s.", al_str_fmt(&http->url));
+ debug("Spawning worker for %.*s.", al_str_fmt(&http->url));
}
static bool handler_http_wait_for_range(struct cch_handler *handler, struct cch_handler_wait *wait)