Commit d60eea31 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Logger: Add dots to the messages

parent cbcb1728
......@@ -41,16 +41,16 @@ const char *logger_offset_name[logger_offset_count] = {
*/
void header_print(const struct header *h) {
#ifdef SWIFT_DEBUG_CHECKS
message("Debug checks enabled");
message("Debug checks enabled.");
#endif
message("First Offset: %lu", h->offset_first_record);
message("Offset direction: %s", logger_offset_name[h->offset_direction]);
message("Number masks: %i", h->number_mask);
message("First Offset: %lu.", h->offset_first_record);
message("Offset direction: %s.", logger_offset_name[h->offset_direction]);
message("Number masks: %i.", h->number_mask);
for (size_t i = 0; i < h->number_mask; i++) {
message(" Mask: %s", h->masks[i].name);
message(" Value: %u", h->masks[i].mask);
message(" Size: %i", h->masks[i].size);
message(" Mask: %s.", h->masks[i].name);
message(" Value: %u.", h->masks[i].mask);
message(" Size: %i.", h->masks[i].size);
message("");
}
};
......@@ -113,7 +113,7 @@ void header_read(struct header *h, struct logger_logfile *log) {
char file_format[STRING_SIZE];
map = logger_loader_io_read_data(map, LOGGER_VERSION_SIZE, &file_format);
if (strcmp(file_format, "SWIFT_LOGGER"))
error("Wrong file format (%s)", file_format);
error("Wrong file format (%s).", file_format);
/* Read the major version number. */
map = logger_loader_io_read_data(map, sizeof(int), &h->major_version);
......@@ -125,14 +125,14 @@ void header_read(struct header *h, struct logger_logfile *log) {
if (&reader->log != log) error("Wrong link to the reader.");
if (reader->verbose > 0)
message("File version %i.%i", h->major_version, h->minor_version);
message("File version %i.%i.", h->major_version, h->minor_version);
/* Read the offset directions. */
map = logger_loader_io_read_data(map, sizeof(int), &h->offset_direction);
if (!header_is_forward(h) && !header_is_backward(h) &&
!header_is_corrupted(h))
error("Wrong offset value in the header (%i)", h->offset_direction);
error("Wrong offset value in the header (%i).", h->offset_direction);
/* Read offset to first record. */
map = logger_loader_io_read_data(map, LOGGER_OFFSET_SIZE,
......@@ -144,7 +144,7 @@ void header_read(struct header *h, struct logger_logfile *log) {
/* Check if value defined in this file is large enough. */
if (STRING_SIZE < h->string_length) {
error("Name too large in log file %i", h->string_length);
error("Name too large in log file %i.", h->string_length);
}
/* Read the number of masks. */
......@@ -170,7 +170,7 @@ void header_read(struct header *h, struct logger_logfile *log) {
if (map != log->log.map + h->offset_first_record) {
header_print(h);
size_t offset = map - log->log.map;
error("Wrong header size (in header %zi, current %zi)",
error("Wrong header size (in header %zi, current %zi).",
h->offset_first_record, offset);
}
};
......
......@@ -35,7 +35,7 @@
size_t logger_loader_io_get_file_size(int fd) {
struct stat s;
int status = fstat(fd, &s);
if (status != 0) error("Unable to get file size (%s)", strerror(errno));
if (status != 0) error("Unable to get file size (%s).", strerror(errno));
return s.st_size;
}
......@@ -59,7 +59,7 @@ void *logger_loader_io_mmap_file(char *filename, size_t *file_size,
else
fd = open(filename, O_RDWR);
if (fd == -1) error("Unable to open file %s (%s)", filename, strerror(errno));
if (fd == -1) error("Unable to open file %s (%s).", filename, strerror(errno));
/* get the file size. */
*file_size = logger_loader_io_get_file_size(fd);
......@@ -70,7 +70,7 @@ void *logger_loader_io_mmap_file(char *filename, size_t *file_size,
void *map = mmap(NULL, *file_size, mode, MAP_SHARED, fd, 0);
if (map == MAP_FAILED)
error("Failed to allocate map of size %zi bytes. (%s)", *file_size,
error("Failed to allocate map of size %zi bytes (%s).", *file_size,
strerror(errno));
/* Close the file. */
......@@ -89,6 +89,6 @@ void *logger_loader_io_mmap_file(char *filename, size_t *file_size,
void logger_loader_io_munmap_file(void *map, size_t file_size) {
/* unmap the file. */
if (munmap(map, file_size) != 0) {
error("Unable to unmap the file (%s)", strerror(errno));
error("Unable to unmap the file (%s).", strerror(errno));
}
}
......@@ -60,7 +60,7 @@ void logger_logfile_init_from_file(struct logger_logfile *log, char *filename,
/* Check if the offset are corrupted. */
if (header_is_corrupted(&log->header)) {
error("The offsets have been corrupted");
error("The offsets have been corrupted.");
}
/* Reverse the offsets direction. */
......@@ -143,7 +143,7 @@ void logger_logfile_reverse_offset(struct logger_logfile *log, char *filename) {
}
if (reader->verbose > 0) {
message("Reversing done");
message("Reversing done.");
}
/* Now that the offset are effectively reversed, can set the direction to
......
......@@ -33,15 +33,15 @@
* @param p The #logger_particle to print
*/
void logger_particle_print(const struct logger_particle *p) {
message("ID: %lu\n", p->id);
message("Mass: %g\n", p->mass);
message("Time: %g\n", p->time);
message("Cutoff Radius: %g\n", p->h);
message("Positions: (%g, %g, %g)\n", p->pos[0], p->pos[1], p->pos[2]);
message("Velocities: (%g, %g, %g)\n", p->vel[0], p->vel[1], p->vel[2]);
message("Accelerations: (%g, %g, %g)\n", p->acc[0], p->acc[1], p->acc[2]);
message("Entropy: %g\n", p->entropy);
message("Density: %g\n", p->density);
message("ID: %lu.", p->id);
message("Mass: %g", p->mass);
message("Time: %g.", p->time);
message("Cutoff Radius: %g.", p->h);
message("Positions: (%g, %g, %g).", p->pos[0], p->pos[1], p->pos[2]);
message("Velocities: (%g, %g, %g).", p->vel[0], p->vel[1], p->vel[2]);
message("Accelerations: (%g, %g, %g).", p->acc[0], p->acc[1], p->acc[2]);
message("Entropy: %g.", p->entropy);
message("Density: %g.", p->density);
}
/**
......@@ -93,7 +93,7 @@ void *logger_particle_read_field(struct logger_particle *part, void *map,
} else if (strcmp("consts", field) == 0) {
p = malloc(size);
} else {
error("Type %s not defined", field);
error("Type %s not defined.", field);
}
/* read the data. */
......@@ -144,7 +144,7 @@ size_t logger_particle_read(struct logger_particle *part,
map = logger_loader_io_read_mask(h, map + offset, &mask, &h_offset);
/* Check if it is not a time record. */
if (mask == 128) error("Unexpected mask: %lu", mask);
if (mask == 128) error("Unexpected mask: %lu.", mask);
/* Read all the fields. */
for (size_t i = 0; i < h->number_mask; i++) {
......@@ -208,17 +208,17 @@ void logger_particle_interpolate(struct logger_particle *part_curr,
const double time) {
/* Check that a particle is provided. */
if (!part_curr) error("part_curr is NULL");
if (!part_next) error("part_next is NULL");
if (!part_curr) error("part_curr is NULL.");
if (!part_next) error("part_next is NULL.");
#ifdef SWIFT_DEBUG_CHECKS
/* Check the particle order. */
if (part_next->time <= part_curr->time)
error("Wrong particle order (next before current)");
error("Wrong particle order (next before current).");
if ((time < part_curr->time) || (part_next->time < time))
error(
"Cannot extrapolate (particle time: %f, "
"interpolating time: %f, next particle time: %f)",
"interpolating time: %f, next particle time: %f).",
part_curr->time, time, part_next->time);
#endif
......
......@@ -67,13 +67,13 @@ static PyObject *loadFromIndex(__attribute__((unused)) PyObject *self,
return NULL;
if (!PyArray_Check(offset)) {
error("Offset is not a numpy array");
error("Offset is not a numpy array.");
}
if (PyArray_NDIM(offset) != 1) {
error("Offset is not a 1 dimensional array");
error("Offset is not a 1 dimensional array.");
}
if (PyArray_TYPE(offset) != NPY_UINT64) {
error("Offset does not contain unsigned int");
error("Offset does not contain unsigned int.");
}
/* initialize the reader. */
......
......@@ -28,7 +28,7 @@
*/
void logger_reader_init(struct logger_reader *reader, char *filename,
int verbose) {
if (verbose > 1) message("Initializing the reader");
if (verbose > 1) message("Initializing the reader.");
/* Initialize the reader variables. */
reader->verbose = verbose;
......@@ -74,7 +74,7 @@ size_t reader_read_record(struct logger_reader *reader,
/* Check if timestamp or not. */
int ind = header_get_field_index(&log->header, "timestamp");
if (ind == -1) {
error("File header does not contain a mask for time");
error("File header does not contain a mask for time.");
}
if (log->header.masks[ind].mask == mask) {
*is_particle = 0;
......
......@@ -49,10 +49,10 @@ size_t time_read(integertime_t *int_time, double *time,
/* check if time mask is present in log file header. */
int ind = header_get_field_index(h, "timestamp");
if (ind == -1) error("File header does not contain a mask for time");
if (ind == -1) error("File header does not contain a mask for time.");
/* check if reading a time record. */
if (h->masks[ind].mask != mask) error("Not a time record");
if (h->masks[ind].mask != mask) error("Not a time record.");
#endif
/* read the record. */
......@@ -79,12 +79,12 @@ size_t time_offset_first_record(const struct header *h) {
/* Check that the first record is really a time record. */
int i = header_get_field_index(h, "timestamp");
if (i == -1) error("Time mask not present in the log file header");
if (i == -1) error("Time mask not present in the log file header.");
size_t mask = 0;
logger_loader_io_read_mask(h, map + offset, &mask, NULL);
if (mask != h->masks[i].mask) error("Log file should begin by timestep");
if (mask != h->masks[i].mask) error("Log file should begin by timestep.");
return h->offset_first_record;
}
......@@ -185,7 +185,7 @@ struct time_array *time_array_get_time_array(const struct time_array *t,
const size_t offset) {
#ifdef SWIFT_DEBUG_CHECKS
if (!t) error("NULL pointer");
if (!t) error("NULL pointer.");
#endif
const struct time_array *tmp;
/* Find the time_array with the correct offset. */
......@@ -226,7 +226,7 @@ void time_array_print(const struct time_array *t) {
/* Loop over all elements. */
for (size_t i = 1; i < n; i++) {
if (!t->next) error("Next pointer not initialized %zi", i);
if (!t->next) error("Next pointer not initialized %zi.", i);
t = t->next;
/* Skip the times at the center of the array. */
......
......@@ -42,7 +42,7 @@ int tools_get_next_record(const struct header *h, void *map, size_t *offset,
if (header_is_backward(h))
return _tools_get_next_record_backward(h, map, offset, file_size);
else
error("Offsets are corrupted");
error("Offsets are corrupted.");
}
/**
......@@ -138,7 +138,7 @@ size_t tools_reverse_offset(const struct header *h, void *file_map,
if (prev_offset == cur_offset) return after_current_record;
if (prev_offset > cur_offset)
error("Unexpected offset, header %lu, current %lu", prev_offset,
error("Unexpected offset: header %lu, current %lu.", prev_offset,
cur_offset);
/* modify previous offset. */
......@@ -152,7 +152,7 @@ size_t tools_reverse_offset(const struct header *h, void *file_map,
/* Check if we are not mixing time stamp and particles */
if ((prev_mask != 128 && mask == 128) || (prev_mask == 128 && mask != 128))
error("Unexpected mask: %lu, got %lu", mask, prev_mask);
error("Unexpected mask: %lu, got %lu.", mask, prev_mask);
#endif // SWIFT_DEBUG_CHECKS
......@@ -173,7 +173,7 @@ size_t tools_reverse_offset(const struct header *h, void *file_map,
size_t tools_check_record_consistency(const struct logger_reader *reader,
size_t offset) {
#ifndef SWIFT_DEBUG_CHECKS
error("Should not check in non debug mode");
error("Should not check in non debug mode.");
#endif
const struct header *h = &reader->log.header;
......@@ -191,11 +191,11 @@ size_t tools_check_record_consistency(const struct logger_reader *reader,
pointed_offset += offset;
else if (header_is_backward(h)) {
if (offset < pointed_offset)
error("Offset too large (%lu) at %lu with mask %lu", pointed_offset,
error("Offset too large (%lu) at %lu with mask %lu.", pointed_offset,
offset, mask);
pointed_offset = offset - pointed_offset;
} else {
error("Offset are corrupted");
error("Offset are corrupted.");
}
/* set offset after current record. */
......@@ -212,7 +212,7 @@ size_t tools_check_record_consistency(const struct logger_reader *reader,
/* check if not mixing time stamp and particles. */
if ((pointed_mask != 128 && mask == 128) ||
(pointed_mask == 128 && mask != 128))
error("Error in the offset (mask %lu at %lu != %lu at %lu)", mask, offset,
error("Error in the offset (mask %lu at %lu != %lu at %lu).", mask, offset,
pointed_mask, pointed_offset);
if (pointed_mask == 128) return (size_t)(map - file_init);
......@@ -224,7 +224,7 @@ size_t tools_check_record_consistency(const struct logger_reader *reader,
logger_particle_read(&part, reader, pointed_offset, 0, logger_reader_const);
if (id != part.id)
error("Offset wrong, id incorrect (%lu != %lu) at %lu", id, part.id,
error("Offset wrong, id incorrect (%lu != %lu) at %lu.", id, part.id,
pointed_offset);
return (size_t)(map - file_init);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment