.
This commit is contained in:
parent
5e165c1fad
commit
c7291ead23
3 changed files with 19 additions and 8 deletions
9
colla.c
9
colla.c
|
|
@ -1263,7 +1263,7 @@ os_log_colour_e os_log_level_colours[LOG_COL__COUNT] = {
|
||||||
[LOG_DEBUG] = LOG_COL_BLUE,
|
[LOG_DEBUG] = LOG_COL_BLUE,
|
||||||
[LOG_INFO] = LOG_COL_GREEN,
|
[LOG_INFO] = LOG_COL_GREEN,
|
||||||
[LOG_WARN] = LOG_COL_YELLOW,
|
[LOG_WARN] = LOG_COL_YELLOW,
|
||||||
[LOG_ERR] = LOG_COL_MAGENTA,
|
[LOG_ERR] = LOG_COL_RED,
|
||||||
[LOG_FATAL] = LOG_COL_RED,
|
[LOG_FATAL] = LOG_COL_RED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1283,20 +1283,21 @@ void os_log__stdout(log_event_t *ev) {
|
||||||
ev->time->tm_min,
|
ev->time->tm_min,
|
||||||
ev->time->tm_sec
|
ev->time->tm_sec
|
||||||
);
|
);
|
||||||
|
os_log_set_colour(LOG_COL_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
os_log_set_colour(os_log_level_colours[ev->level]);
|
|
||||||
if (ev->level != LOG_BASIC) {
|
if (ev->level != LOG_BASIC) {
|
||||||
|
os_log_set_colour(os_log_level_colours[ev->level]);
|
||||||
fmt_print("%-8s ", os_log_level_strings[ev->level]);
|
fmt_print("%-8s ", os_log_level_strings[ev->level]);
|
||||||
|
os_log_set_colour(LOG_COL_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nofile) {
|
if (!nofile) {
|
||||||
os_log_set_colour(LOG_COL_DARK_GREY);
|
os_log_set_colour(LOG_COL_DARK_GREY);
|
||||||
fmt_print("%s:%d ", ev->file, ev->line);
|
fmt_print("%s:%d ", ev->file, ev->line);
|
||||||
|
os_log_set_colour(LOG_COL_RESET);
|
||||||
}
|
}
|
||||||
|
|
||||||
os_log_set_colour(LOG_COL_RESET);
|
|
||||||
|
|
||||||
fmt_printv(ev->fmt, ev->args);
|
fmt_printv(ev->fmt, ev->args);
|
||||||
fmt_print("\n");
|
fmt_print("\n");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
colla.h
2
colla.h
|
|
@ -1319,7 +1319,7 @@ typedef struct {
|
||||||
strview_t body;
|
strview_t body;
|
||||||
} http_request_desc_t;
|
} http_request_desc_t;
|
||||||
|
|
||||||
typedef void (*http_request_callback_fn)(strview_t chunk, void *udata);
|
typedef void (*http_request_callback_fn)(http_header_t *headers, strview_t chunk, void *udata);
|
||||||
|
|
||||||
// arena_t *arena, strview_t url, [ http_header_t *headers, int header_count, strview_t body ]
|
// arena_t *arena, strview_t url, [ http_header_t *headers, int header_count, strview_t body ]
|
||||||
#define http_get(arena, url, ...) http_request(&(http_request_desc_t){ arena, url, .request_type = HTTP_GET, .version = { 1, 1 }, __VA_ARGS__ })
|
#define http_get(arena, url, ...) http_request(&(http_request_desc_t){ arena, url, .request_type = HTTP_GET, .version = { 1, 1 }, __VA_ARGS__ })
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,16 @@ void os__win_free_entity(os_entity_t *entity) {
|
||||||
list_push(w32_data.entity_free, entity);
|
list_push(w32_data.entity_free, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HANDLE os__win_get_handle(oshandle_t handle) {
|
||||||
|
os_entity_t *e = (os_entity_t *)handle.data;
|
||||||
|
switch (e->kind) {
|
||||||
|
case OS_KIND_THREAD:
|
||||||
|
return e->thread.handle;
|
||||||
|
default:
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void os_init(void) {
|
void os_init(void) {
|
||||||
SetConsoleOutputCP(CP_UTF8);
|
SetConsoleOutputCP(CP_UTF8);
|
||||||
|
|
||||||
|
|
@ -288,7 +298,7 @@ os_wait_t os_wait_on_handles(oshandle_t *handles, int count, bool wait_all, u32
|
||||||
colla_assert(count < COLLA_OS_MAX_WAITABLE_HANDLES);
|
colla_assert(count < COLLA_OS_MAX_WAITABLE_HANDLES);
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i) {
|
for (int i = 0; i < count; ++i) {
|
||||||
win_handles[i] = (HANDLE)(handles[i].data);
|
win_handles[i] = os__win_get_handle(handles[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD result = WaitForMultipleObjects(count, win_handles, wait_all, milliseconds);
|
DWORD result = WaitForMultipleObjects(count, win_handles, wait_all, milliseconds);
|
||||||
|
|
@ -720,7 +730,7 @@ oshandle_t os_run_cmd_async(arena_t scratch, os_cmd_t *cmd, os_cmd_options_t *op
|
||||||
for (int i = 0; i < cur->count; ++i) {
|
for (int i = 0; i < cur->count; ++i) {
|
||||||
strview_t arg = cur->items[i];
|
strview_t arg = cur->items[i];
|
||||||
if (strv_contains(arg, ' ')) {
|
if (strv_contains(arg, ' ')) {
|
||||||
ostr_print(&cmdline, "%v", arg);
|
ostr_print(&cmdline, "\"%v\"", arg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ostr_puts(&cmdline, arg);
|
ostr_puts(&cmdline, arg);
|
||||||
|
|
@ -1195,7 +1205,7 @@ http_res_t http_request_cb(http_request_desc_t *req, http_request_callback_fn ca
|
||||||
|
|
||||||
strview_t chunk = strv(read_buffer, read);
|
strview_t chunk = strv(read_buffer, read);
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(chunk, userdata);
|
callback(res.headers, chunk, userdata);
|
||||||
}
|
}
|
||||||
ostr_puts(&body, chunk);
|
ostr_puts(&body, chunk);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue