Update code

This commit is contained in:
Nick Peng
2018-07-30 23:37:11 +08:00
parent 1d0695ff7f
commit edfc7a1d15
7 changed files with 213 additions and 41 deletions

View File

@@ -34,6 +34,7 @@
#define TLOG_LOG_SIZE (1024 * 1024 * 50)
#define TLOG_LOG_COUNT 32
#define TLOG_LOG_NAME_LEN 128
#define TLOG_BUFF_LEN (PATH_MAX + TLOG_LOG_NAME_LEN * 2)
struct oldest_log {
char name[TLOG_TMP_LEN];
@@ -383,7 +384,7 @@ int tlog_ext(tlog_level level, const char *file, int line, const char *func, voi
static int _tlog_rename_logfile(const char *gzip_file)
{
char archive_file[PATH_MAX * 2];
char archive_file[TLOG_BUFF_LEN];
struct tlog_time logtime;
int i = 0;
@@ -461,7 +462,7 @@ static int _tlog_count_log_callback(const char *path, struct dirent *entry, void
static int _tlog_get_oldest_callback(const char *path, struct dirent *entry, void *userptr)
{
struct stat sb;
char filename[PATH_MAX * 2];
char filename[TLOG_BUFF_LEN];
struct oldest_log *oldestlog = userptr;
/* if not a gz file, skip */
@@ -647,10 +648,10 @@ errout:
static int _tlog_archive_log(void)
{
char gzip_file[PATH_MAX * 2];
char gzip_file[TLOG_BUFF_LEN];
char gzip_cmd[PATH_MAX * 2];
char log_file[PATH_MAX * 2];
char pending_file[PATH_MAX * 2];
char log_file[TLOG_BUFF_LEN];
char pending_file[TLOG_BUFF_LEN];
snprintf(gzip_file, sizeof(gzip_file), "%s/%s.pending.gz", tlog.logdir, tlog.logname);
snprintf(pending_file, sizeof(pending_file), "%s/%s.pending", tlog.logdir, tlog.logname);