X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?p=sim%2Fo1-interface.git;a=blobdiff_plain;f=ntsimulator%2Fntsim-ng%2Futils%2Flog_utils.c;h=006ee46a4974de8dcf849b4ef7c58735ec10be82;hp=b0e26afb25bac213ead7080ca8607e3e744660c9;hb=c7e43513c1c4c3569d5079db0a9a31c124274e6c;hpb=908fe04b071e17feb1984cbc342ab9f45f325e18 diff --git a/ntsimulator/ntsim-ng/utils/log_utils.c b/ntsimulator/ntsim-ng/utils/log_utils.c index b0e26af..006ee46 100644 --- a/ntsimulator/ntsim-ng/utils/log_utils.c +++ b/ntsimulator/ntsim-ng/utils/log_utils.c @@ -37,6 +37,10 @@ static int instances = 0; static FILE* logfile = 0; +static int file_no = 0; +static int line_no = 0; +static const char *filename; + static char *extract_format(const char *format); void log_init(const char *logfilename) { @@ -46,9 +50,24 @@ void log_init(const char *logfilename) { logfile = fopen(logfilename, "w"); assert(logfile); + file_no = 0; + line_no = 0; + filename = logfilename; } void log__message(char const * const fname, uint32_t location, int verbose_level, const char *format, ...) { + if(verbose_level >= 0) { + line_no++; + if(line_no >= 5000) { + fclose(logfile); + + file_no++; + char logfilename[512]; + sprintf(logfilename, "%s.%d", filename, file_no); + logfile = fopen(logfilename, "w"); + line_no = 0; + } + } va_list arg;