Skip to content

Commit

Permalink
1.add more information for command info and config get
Browse files Browse the repository at this point in the history
2.fix log file symbol link error
  • Loading branch information
fortrue committed Dec 26, 2017
1 parent bd9d2ed commit 4566164
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/Handler.cpp
Expand Up @@ -899,7 +899,8 @@ void Handler::infoRequest(Request* req, const String& key)
#define Scope(all, empty, header) ((all || empty || key.equal(header, true)) ? \
(buf = buf->fappend("# %s\n", header)) : nullptr)

if (Scope(all, empty, "Proxy")) {
if (all || empty || key.equal("Proxy", true) || key.equal("Server", true)) {
buf = buf->fappend("# %s\n", "Proxy");
buf = buf->fappend("Version:%s\n", _PREDIXY_VERSION_);
buf = buf->fappend("Name:%s\n", mProxy->conf()->name());
buf = buf->fappend("Bind:%s\n", mProxy->conf()->bind());
Expand Down Expand Up @@ -1196,6 +1197,11 @@ void Handler::configGetRequest(Request* req)
}

do {
Append("Name", "%s", conf->name());
Append("Bind", "%s", conf->bind());
Append("WorkerThreads", "%d", conf->workerThreads());
Append("BufSize", "%d", Buffer::getSize());
Append("LocalDC", "%s", conf->localDC().c_str());
Append("MaxMemory", "%ld", AllocBase::getMaxMemory());
Append("ClientTimeout", "%d", conf->clientTimeout() / 1000000);
Append("AllowMissLog", "%s", log->allowMissLog() ? "true" : "false");
Expand Down
10 changes: 6 additions & 4 deletions src/LogFileSink.cpp
Expand Up @@ -118,7 +118,9 @@ bool LogFileSink::reopen(time_t t)
}
if (mFileSuffixFmt) {
unlink(mFileName.c_str());
if (symlink(mFilePath, mFileName.c_str()) == -1) {
const char* name = strrchr(mFilePath, '/');
name = name ? name + 1 : mFilePath;
if (symlink(name, mFileName.c_str()) == -1) {
fprintf(stderr, "create symbol link for %s fail", mFileName.c_str());
}
}
Expand All @@ -135,9 +137,9 @@ bool LogFileSink::setFile(const char* path, int rotateSecs, long rotateBytes)
if (len > 4 && strcasecmp(path + len - 4, ".log") == 0) {
len -= 4;
}
if (len + FileSuffixReserveLen >= MaxPathLen) {
return false;
}
}
if (len + FileSuffixReserveLen >= MaxPathLen) {
return false;
}
mFileName = path;
mFilePathLen = len;
Expand Down

0 comments on commit 4566164

Please sign in to comment.