MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / ldbLogWithMaxLen

Function ldbLogWithMaxLen

src/scripting.cpp:1915–1928  ·  view source on GitHub ↗

A version of ldbLog() which prevents producing logs greater than * ldb.maxlen. The first time the limit is reached a hint is generated * to inform the user that reply trimming can be disabled using the * debugger "maxlen" command. */

Source from the content-addressed store, hash-verified

1913 * to inform the user that reply trimming can be disabled using the
1914 * debugger "maxlen" command. */
1915void ldbLogWithMaxLen(sds entry) {
1916 int trimmed = 0;
1917 if (ldb.maxlen && sdslen(entry) > ldb.maxlen) {
1918 sdsrange(entry,0,ldb.maxlen-1);
1919 entry = sdscatlen(entry," ...",4);
1920 trimmed = 1;
1921 }
1922 ldbLog(entry);
1923 if (trimmed && ldb.maxlen_hint_sent == 0) {
1924 ldb.maxlen_hint_sent = 1;
1925 ldbLog(sdsnew(
1926 "<hint> The above reply was trimmed. Use 'maxlen 0' to disable trimming."));
1927 }
1928}
1929
1930/* Send ldb.logs to the debugging client as a multi-bulk reply
1931 * consisting of simple strings. Log entries which include newlines have them

Callers 2

ldbLogStackValueFunction · 0.85
ldbLogRedisReplyFunction · 0.85

Calls 5

sdslenFunction · 0.85
sdsrangeFunction · 0.85
sdscatlenFunction · 0.85
ldbLogFunction · 0.85
sdsnewFunction · 0.85

Tested by

no test coverage detected