Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions zlog/src/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,38 @@ int zlog_buf_vprintf(zlog_buf_t * a_buf, const char *format, va_list args)
//*(a_buf->tail) = '\0';
return 0;
} else if (nwrite < 0) {
zc_error("vsnprintf fail, errno[%d]", errno);
zc_error("nwrite[%d], size_left[%ld], format[%s]", nwrite, size_left, format);
#ifdef _MSC_VER
int rc;
do
{
rc = zlog_buf_resize(a_buf, a_buf->size_real * 2);
if (rc > 0) {
zc_error("conf limit to %ld, can't extend, so truncate", a_buf->size_max);
ap = args;
size_left = a_buf->end_plus_1 - a_buf->start;
vsnprintf(a_buf->tail, size_left, format, ap);
a_buf->tail += size_left - 1;
//*(a_buf->tail) = '\0';
zlog_buf_truncate(a_buf);
return 1;
} else if (rc < 0) {
zc_error("zlog_buf_resize fail");
return -1;
} else {
ap = args;
size_left = a_buf->end_plus_1 - a_buf->tail;
nwrite = vsnprintf(a_buf->tail, size_left, format, ap);
if (nwrite >0) {
break;
}
}
} while (rc == 0);
//zc_debug("nwrite[%d]>=size_left[%ld],format[%s],resize", nwrite, size_left, format);

#else
zc_error("vsnprintf fail, errno[%d]", errno);
zc_error("nwrite[%d], size_left[%ld], format[%s]", nwrite, size_left, format);
#endif
return -1;
} else if (nwrite >= size_left) {
int rc;
Expand Down
6 changes: 4 additions & 2 deletions zlog/src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@
#define ZLOG_CONF_DEFAULT_RELOAD_CONF_PERIOD 0
#define ZLOG_CONF_DEFAULT_FSYNC_PERIOD 0
#ifdef _MSC_VER
#define ZLOG_CONF_BACKUP_ROTATE_LOCK_FILE "d:/tmp/zlog.lock"
#define ZLOG_CONF_BACKUP_ROTATE_LOCK_FILE "zlog.lock"
#else
#define ZLOG_CONF_BACKUP_ROTATE_LOCK_FILE "/tmp/zlog.lock"
#define ZLOG_CONF_BACKUP_ROTATE_LOCK_FILE "zlog.lock"
#endif
/*******************************************************************************/

zlog_conf_t *zlog_env_conf;

void zlog_conf_profile(zlog_conf_t * a_conf, int flag)
{
int i;
Expand Down
4 changes: 3 additions & 1 deletion zlog/src/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ typedef struct zlog_conf_s {
zc_arraylist_t *rules;
} zlog_conf_t;

extern zlog_conf_t * zlog_env_conf;


zlog_conf_t *zlog_conf_new(const char *confpath);
void zlog_conf_del(zlog_conf_t * a_conf);
void zlog_conf_profile(zlog_conf_t * a_conf, int flag);

extern zlog_conf_t * zlog_env_conf;

#endif
4 changes: 2 additions & 2 deletions zlog/src/zc_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ int zc_profile_inner(int flag, const char *file, const long line, const char *fm

if (!init_flag) {
init_flag = 1;
_putenv( "ZLOG_PROFILE_DEBUG=d:\\tmp\\debug.log" ); // C4996
_putenv( "ZLOG_PROFILE_ERROR=d:\\tmp\\error.log" ); // C4996
_putenv( "ZLOG_PROFILE_DEBUG=log/debug.log" ); // C4996
_putenv( "ZLOG_PROFILE_ERROR=log/error.log" ); // C4996
debug_log = getenv("ZLOG_PROFILE_DEBUG");
error_log = getenv("ZLOG_PROFILE_ERROR");
printf("debug_log:%s\n",debug_log);
Expand Down
5 changes: 5 additions & 0 deletions zlog/src/zc_xplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@
#define MAXLEN_PATH 1024
#define MAXLEN_CFG_LINE (MAXLEN_PATH * 4)

#ifdef _MSC_VER
#define FILE_NEWLINE "\r\n"
#define FILE_NEWLINE_LEN 2
#else
#define FILE_NEWLINE "\n"
#define FILE_NEWLINE_LEN 1
#endif

#include <string.h>
#ifndef _MSC_VER
Expand Down