}
}
-static void log_cat_exit(xbt_log_category_t cat)
+static void log_cat_exit(const s_xbt_log_category_t* cat)
{
xbt_log_category_t child;
cat->isThreshInherited = 1;
}
-static void _set_inherited_thresholds(xbt_log_category_t cat)
+static void _set_inherited_thresholds(const s_xbt_log_category_t* cat)
{
xbt_log_category_t child = cat->firstChild;
cats.push_back(cat);
std::sort(begin(cats), end(cats),
- [](xbt_log_category_t a, xbt_log_category_t b) { return strcmp(a->name, b->name) < 0; });
+ [](const s_xbt_log_category_t* a, const s_xbt_log_category_t* b) { return strcmp(a->name, b->name) < 0; });
for (auto const& cat : cats) {
XBT_HELP("%s%s: %s", this_prefix.c_str(), cat->name, cat->description);
#include "xbt/log.h"
struct xbt_log_appender_s {
- void (*do_append) (xbt_log_appender_t this_appender, char *event);
- void (*free_) (xbt_log_appender_t this_);
+ void (*do_append)(const s_xbt_log_appender_t* this_appender, const char* event);
+ void (*free_)(const s_xbt_log_appender_t* this_);
void *data;
};
struct xbt_log_layout_s {
- int (*do_layout) (xbt_log_layout_t l, xbt_log_event_t event, const char *fmt);
- void (*free_) (xbt_log_layout_t l);
+ int (*do_layout)(const s_xbt_log_layout_t* l, xbt_log_event_t event, const char* fmt);
+ void (*free_)(const s_xbt_log_layout_t* l);
void *data;
};
#include <cstdio>
#include <cstring>
-static void append_file(xbt_log_appender_t this_, char *str) {
+static void append_file(const s_xbt_log_appender_t* this_, const char* str)
+{
fputs(str, (FILE *) this_->data);
}
-static void free_(xbt_log_appender_t this_)
+static void free_(const s_xbt_log_appender_t* this_)
{
fclose(static_cast<FILE*>(this_->data));
}
}
}
-static void append2_file(xbt_log_appender_t this_, char *str) {
- xbt_log_append2_file_t d=(xbt_log_append2_file_t) this_->data;
- xbt_assert(d->file);
- if(ftell(d->file)>=d->limit) {
- open_append2_file(d);
- }
- fputs(str, d->file);
- if(d->count<0){
- fputs(APPEND2_END_TOKEN,d->file);
- fseek(d->file,-((signed long)strlen(APPEND2_END_TOKEN)),SEEK_CUR);
- }
+static void append2_file(const s_xbt_log_appender_t* this_, const char* str)
+{
+ xbt_log_append2_file_t d = (xbt_log_append2_file_t)this_->data;
+ xbt_assert(d->file);
+ if (ftell(d->file) >= d->limit) {
+ open_append2_file(d);
+ }
+ fputs(str, d->file);
+ if (d->count < 0) {
+ fputs(APPEND2_END_TOKEN, d->file);
+ fseek(d->file, -((signed long)strlen(APPEND2_END_TOKEN)), SEEK_CUR);
+ }
}
-static void free_append2_(xbt_log_appender_t this_)
+static void free_append2_(const s_xbt_log_appender_t* this_)
{
xbt_log_append2_file_t data = static_cast<xbt_log_append2_file_t>(this_->data);
if (data->file)
#define show_int(data) show_it((data), "d")
#define show_double(data) show_it((data), "f")
-static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, const char* msg_fmt)
+static int xbt_log_layout_format_doit(const s_xbt_log_layout_t* l, xbt_log_event_t ev, const char* msg_fmt)
{
char *p = ev->buffer;
int rem_size = ev->buffer_size;
return 1;
}
-static void xbt_log_layout_format_free(xbt_log_layout_t lay)
+static void xbt_log_layout_format_free(const s_xbt_log_layout_t* lay)
{
xbt_free(lay->data);
}
p += (len); \
} while (0)
-static int xbt_log_layout_simple_doit(xbt_log_layout_t, xbt_log_event_t ev, const char* fmt)
+static int xbt_log_layout_simple_doit(const s_xbt_log_layout_t*, xbt_log_event_t ev, const char* fmt)
{
char *p = ev->buffer;
int rem_size = ev->buffer_size;