|
@@ -33,6 +33,7 @@
|
|
#define TLOG_TMP_LEN 128
|
|
#define TLOG_TMP_LEN 128
|
|
#define TLOG_LOG_SIZE (1024 * 1024 * 50)
|
|
#define TLOG_LOG_SIZE (1024 * 1024 * 50)
|
|
#define TLOG_LOG_COUNT 32
|
|
#define TLOG_LOG_COUNT 32
|
|
|
|
+#define TLOG_LOG_NAME_LEN 128
|
|
|
|
|
|
struct oldest_log {
|
|
struct oldest_log {
|
|
char name[TLOG_TMP_LEN];
|
|
char name[TLOG_TMP_LEN];
|
|
@@ -59,7 +60,7 @@ struct tlog {
|
|
|
|
|
|
off_t filesize;
|
|
off_t filesize;
|
|
char logdir[PATH_MAX];
|
|
char logdir[PATH_MAX];
|
|
- char logname[PATH_MAX];
|
|
|
|
|
|
+ char logname[TLOG_LOG_NAME_LEN];
|
|
int logsize;
|
|
int logsize;
|
|
int logcount;
|
|
int logcount;
|
|
int block;
|
|
int block;
|
|
@@ -382,7 +383,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)
|
|
static int _tlog_rename_logfile(const char *gzip_file)
|
|
{
|
|
{
|
|
- char archive_file[PATH_MAX];
|
|
|
|
|
|
+ char archive_file[PATH_MAX * 2];
|
|
struct tlog_time logtime;
|
|
struct tlog_time logtime;
|
|
int i = 0;
|
|
int i = 0;
|
|
|
|
|
|
@@ -460,7 +461,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)
|
|
static int _tlog_get_oldest_callback(const char *path, struct dirent *entry, void *userptr)
|
|
{
|
|
{
|
|
struct stat sb;
|
|
struct stat sb;
|
|
- char filename[PATH_MAX];
|
|
|
|
|
|
+ char filename[PATH_MAX * 2];
|
|
struct oldest_log *oldestlog = userptr;
|
|
struct oldest_log *oldestlog = userptr;
|
|
|
|
|
|
/* if not a gz file, skip */
|
|
/* if not a gz file, skip */
|
|
@@ -500,7 +501,7 @@ static int _tlog_remove_oldestlog(void)
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
- char filename[PATH_MAX];
|
|
|
|
|
|
+ char filename[PATH_MAX * 2];
|
|
snprintf(filename, sizeof(filename), "%s/%s", tlog.logdir, oldestlog.name);
|
|
snprintf(filename, sizeof(filename), "%s/%s", tlog.logdir, oldestlog.name);
|
|
|
|
|
|
/* delete */
|
|
/* delete */
|
|
@@ -530,7 +531,7 @@ static int _tlog_remove_oldlog(void)
|
|
|
|
|
|
static void _tlog_log_unlock(void)
|
|
static void _tlog_log_unlock(void)
|
|
{
|
|
{
|
|
- char lock_file[PATH_MAX];
|
|
|
|
|
|
+ char lock_file[PATH_MAX * 2];
|
|
if (tlog.fd_lock <= 0) {
|
|
if (tlog.fd_lock <= 0) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -543,7 +544,7 @@ static void _tlog_log_unlock(void)
|
|
|
|
|
|
static int _tlog_log_lock(void)
|
|
static int _tlog_log_lock(void)
|
|
{
|
|
{
|
|
- char lock_file[PATH_MAX];
|
|
|
|
|
|
+ char lock_file[PATH_MAX * 2];
|
|
int fd;
|
|
int fd;
|
|
|
|
|
|
if (tlog.multi_log == 0) {
|
|
if (tlog.multi_log == 0) {
|
|
@@ -586,7 +587,7 @@ static void _tlog_wait_pid(int wait_hang)
|
|
|
|
|
|
/* gzip process exited */
|
|
/* gzip process exited */
|
|
tlog.zip_pid = -1;
|
|
tlog.zip_pid = -1;
|
|
- char gzip_file[PATH_MAX];
|
|
|
|
|
|
+ char gzip_file[PATH_MAX * 2];
|
|
|
|
|
|
/* rename ziped file */
|
|
/* rename ziped file */
|
|
snprintf(gzip_file, sizeof(gzip_file), "%s/%s.pending.gz", tlog.logdir, tlog.logname);
|
|
snprintf(gzip_file, sizeof(gzip_file), "%s/%s.pending.gz", tlog.logdir, tlog.logname);
|
|
@@ -646,10 +647,10 @@ errout:
|
|
|
|
|
|
static int _tlog_archive_log(void)
|
|
static int _tlog_archive_log(void)
|
|
{
|
|
{
|
|
- char gzip_file[PATH_MAX];
|
|
|
|
- char gzip_cmd[PATH_MAX];
|
|
|
|
- char log_file[PATH_MAX];
|
|
|
|
- char pending_file[PATH_MAX];
|
|
|
|
|
|
+ char gzip_file[PATH_MAX * 2];
|
|
|
|
+ char gzip_cmd[PATH_MAX * 2];
|
|
|
|
+ char log_file[PATH_MAX * 2];
|
|
|
|
+ char pending_file[PATH_MAX * 2];
|
|
|
|
|
|
snprintf(gzip_file, sizeof(gzip_file), "%s/%s.pending.gz", tlog.logdir, tlog.logname);
|
|
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);
|
|
snprintf(pending_file, sizeof(pending_file), "%s/%s.pending", tlog.logdir, tlog.logname);
|
|
@@ -718,7 +719,7 @@ static int _tlog_write_log(char *buff, int bufflen)
|
|
|
|
|
|
if (tlog.fd <= 0) {
|
|
if (tlog.fd <= 0) {
|
|
/* open a new log file to write */
|
|
/* open a new log file to write */
|
|
- char logfile[PATH_MAX];
|
|
|
|
|
|
+ char logfile[PATH_MAX * 2];
|
|
if (_tlog_mkdir(tlog.logdir) != 0) {
|
|
if (_tlog_mkdir(tlog.logdir) != 0) {
|
|
fprintf(stderr, "create log dir %s failed.\n", tlog.logdir);
|
|
fprintf(stderr, "create log dir %s failed.\n", tlog.logdir);
|
|
return -1;
|
|
return -1;
|