diff --git a/uppsrc/Core/Rpc/Rpc.h b/uppsrc/Core/Rpc/Rpc.h index b93e428e1..0b1ef0084 100644 --- a/uppsrc/Core/Rpc/Rpc.h +++ b/uppsrc/Core/Rpc/Rpc.h @@ -346,6 +346,7 @@ struct JsonRpcRequestNamed : RpcRequest { void LogRpcRequests(bool b = true); void SetRpcServerTrace(Stream& s, int level = 1); +void SetRpcServerTraceCompress(bool compress); void StopRpcServerTrace(); void SuppressRpcServerTraceForMethodCall(); diff --git a/uppsrc/Core/Rpc/Server.cpp b/uppsrc/Core/Rpc/Server.cpp index 089aaa9c2..872e91883 100644 --- a/uppsrc/Core/Rpc/Server.cpp +++ b/uppsrc/Core/Rpc/Server.cpp @@ -48,6 +48,7 @@ void ThrowRpcError(const char *s) static Stream *rpc_trace, *suppressed_rpc_trace; static int rpc_trace_level; +static bool rpc_trace_compress = true; void SetRpcServerTrace(Stream& s, int level) { @@ -55,6 +56,11 @@ void SetRpcServerTrace(Stream& s, int level) rpc_trace_level = level; } +void SetRpcServerTraceCompress(bool compress) +{ + rpc_trace_compress = compress; +} + void StopRpcServerTrace() { rpc_trace = NULL; @@ -71,8 +77,14 @@ bool CallRpcMethod(RpcData& data, const char *group, String methodname, const St LLOG("method name: " << methodname); if(sRpcMethodFilter) methodname = (*sRpcMethodFilter)(methodname); - if(rpc_trace) - *rpc_trace << "RPC Request:\n" << request << '\n'; + if(rpc_trace) { + *rpc_trace << "RPC Request:\n"; + if(rpc_trace_compress) + *rpc_trace << CompressLog(request); + else + *rpc_trace << request; + *rpc_trace << '\n'; + } void (*fn)(RpcData&) = RpcMapGet(group, methodname); if(!fn) return false; diff --git a/uppsrc/Core/Util.cpp b/uppsrc/Core/Util.cpp index 6d0f7f356..3c85ea829 100644 --- a/uppsrc/Core/Util.cpp +++ b/uppsrc/Core/Util.cpp @@ -536,6 +536,30 @@ Vector GetCsvLine(Stream& s, int separator, byte charset) } } +String CompressLog(const char *s) +{ + StringBuffer result; + while(*s) { + const char *b = s; + while(IsSpace(*s)) + s++; + result.Cat(b, s); + if(!*s) + break; + b = s; + while(*s && !IsSpace(*s)) + s++; + if(s - b > 200) { + result.Cat(b, 20); + result.Cat("....", 4); + result.Cat(s - 20, 20); + } + else + result.Cat(b, s); + } + return result; +} + int ChNoInvalid(int c) { return c == DEFAULTCHAR ? '_' : c; diff --git a/uppsrc/Core/Util.h b/uppsrc/Core/Util.h index b45aa8dec..9714841a0 100644 --- a/uppsrc/Core/Util.h +++ b/uppsrc/Core/Util.h @@ -234,6 +234,8 @@ String NormalizeSpaces(const char *begin, const char *end); String CsvString(const String& text); Vector GetCsvLine(Stream& s, int separator, byte charset); +String CompressLog(const char *s); + #ifndef PLATFORM_WIN32 void Sleep(int msec); #endif