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. */
| 1913 | * to inform the user that reply trimming can be disabled using the |
| 1914 | * debugger "maxlen" command. */ |
| 1915 | void 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 |