I'm trying to run the following code:
(log4e--logging " *log4e-alert*" nil "%t [%l] %m" "%H:%M:%S" normal nil t info "ETag stale for 1:1 Robert\\Sunny")
The string we're trying to log contains a literal backslash. This throws the following error:
Debugger entered--Lisp error: (error "Invalid use of ‘\\’ in replacement text")
replace-regexp-in-string("%m" "ETag stale for 1:1 Robert\\Sunny" #("12:34:11 [INFO ] %m" 0 8 (face font-lock-doc-face) 10 15 (face font-lock-keyword-face)))
log4e--logging(" *log4e-alert*" nil "%t [%l] %m" "%H:%M:%S" normal nil t info "ETag stale for 1:1 Robert\\Sunny")
This can be traced to the following code in log4e--insert-log:
(logtext (replace-regexp-in-string "%t" timetext logtext))
(logtext (replace-regexp-in-string "%l" lvltext logtext))
(logtext (replace-regexp-in-string "%m" msg logtext))
All of these (as well as any use case where log4e attempts to use a user-provided string as replacement text) should set the optional 5th argument LITERAL to replace-regexp-in-string to non-nil to avoid interpreting backslash escapes (such as \1 to match groups in the regexp). It would also be a good idea to set the 4th argument FIXEDCASE as well.
I will work around it for now in my code by escaping the backslashes myself, but it would be good to fix this. When this is fixed, it would be good to bump the version number, so that clients can selectively escape based on the version number.
log4e commit 737d275 version 0.3.3
Emacs 28.1
I'm trying to run the following code:
The string we're trying to log contains a literal backslash. This throws the following error:
This can be traced to the following code in
log4e--insert-log:All of these (as well as any use case where
log4eattempts to use a user-provided string as replacement text) should set the optional 5th argumentLITERALtoreplace-regexp-in-stringto non-nil to avoid interpreting backslash escapes (such as\1to match groups in the regexp). It would also be a good idea to set the 4th argumentFIXEDCASEas well.I will work around it for now in my code by escaping the backslashes myself, but it would be good to fix this. When this is fixed, it would be good to bump the version number, so that clients can selectively escape based on the version number.
log4e commit 737d275 version 0.3.3
Emacs 28.1