write a log class to record and fix a realloc bug