mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-07 12:43:14 +02:00
Newlog: add log_data_channel(). TODO: expand a lot more.
This commit is contained in:
@@ -1111,6 +1111,7 @@ extern LogData *log_data_char(const char *key, const char c);
|
||||
extern LogData *log_data_integer(const char *key, int64_t integer);
|
||||
extern LogData *log_data_timestamp(const char *key, time_t ts);
|
||||
extern LogData *log_data_client(const char *key, Client *client);
|
||||
extern LogData *log_data_channel(const char *key, Channel *channel);
|
||||
extern LogData *log_data_source(const char *file, int line, const char *function);
|
||||
extern LogData *log_data_socket_error(int fd);
|
||||
extern LogData *log_data_link_block(ConfigItem_link *link);
|
||||
|
||||
@@ -210,6 +210,7 @@ typedef enum LogFieldType {
|
||||
LOG_FIELD_INTEGER, // and unsigned?
|
||||
LOG_FIELD_STRING,
|
||||
LOG_FIELD_CLIENT,
|
||||
LOG_FIELD_CHANNEL,
|
||||
LOG_FIELD_OBJECT
|
||||
} LogFieldType;
|
||||
|
||||
@@ -220,6 +221,7 @@ typedef struct LogData {
|
||||
int64_t integer;
|
||||
char *string;
|
||||
Client *client;
|
||||
Channel *channel;
|
||||
json_t *object;
|
||||
} value;
|
||||
} LogData;
|
||||
|
||||
@@ -517,6 +517,7 @@ void json_expand_channel(json_t *j, char *key, Channel *channel, int detail)
|
||||
json_t *child = json_object();
|
||||
json_object_set_new(j, key, child);
|
||||
json_object_set_new(child, "name", json_string_unreal(channel->name));
|
||||
// TODO: expand more, obviously!
|
||||
}
|
||||
|
||||
char *timestamp_iso8601_now(void)
|
||||
@@ -614,6 +615,15 @@ LogData *log_data_client(const char *key, Client *client)
|
||||
return d;
|
||||
}
|
||||
|
||||
LogData *log_data_channel(const char *key, Channel *channel)
|
||||
{
|
||||
LogData *d = safe_alloc(sizeof(LogData));
|
||||
d->type = LOG_FIELD_CHANNEL;
|
||||
safe_strdup(d->key, key);
|
||||
d->value.channel = channel;
|
||||
return d;
|
||||
}
|
||||
|
||||
LogData *log_data_source(const char *file, int line, const char *function)
|
||||
{
|
||||
LogData *d = safe_alloc(sizeof(LogData));
|
||||
@@ -1427,6 +1437,9 @@ void do_unreal_log_internal(LogLevel loglevel, char *subsystem, char *event_id,
|
||||
case LOG_FIELD_CLIENT:
|
||||
json_expand_client(j_details, d->key, d->value.client, 0);
|
||||
break;
|
||||
case LOG_FIELD_CHANNEL:
|
||||
json_expand_channel(j_details, d->key, d->value.channel, 0);
|
||||
break;
|
||||
case LOG_FIELD_OBJECT:
|
||||
json_object_set_new(j_details, d->key, d->value.object);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user