File tree Expand file tree Collapse file tree
java/src/com/google/template/soy Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727import com .google .template .soy .data .LoggingAdvisingAppendable ;
2828import com .google .template .soy .data .LoggingFunctionInvocation ;
2929import com .google .template .soy .logging .SoyLogger ;
30+ import com .google .template .soy .logging .SoyLogger .LoggingAttrs ;
3031import java .io .IOException ;
3132import java .util .Optional ;
3233import java .util .function .Function ;
@@ -173,7 +174,7 @@ public LoggingAdvisingAppendable enterLoggableElement(LogStatement statement) {
173174 }
174175 var enterData = logger .enter (statement );
175176 appendDebugOutput (enterData .debugHtml ());
176- var loggingAttrs = enterData .loggingAttrs ().orElse (null );
177+ LoggingAttrs loggingAttrs = enterData .loggingAttrs ().orElse (null );
177178 if (loggingAttrs != null && depth > 0 ) {
178179 loggingAttrs = null ; // we cannot render them when logonly is set, so drop them now.
179180 }
@@ -199,7 +200,7 @@ public LoggingAdvisingAppendable exitLoggableElement() {
199200 }
200201
201202 private void setLoggingAttrs (@ Nullable SoyLogger .LoggingAttrs loggingAttrs ) {
202- if (this . loggingAttrs != null ) {
203+ if (loggingAttrs != null && loggingAttrs . hasOverlappingAttributes ( this . loggingAttrs ) ) {
203204 googleLogger .atWarning ().withStackTrace (StackSize .LARGE ).log (
204205 "a logger configured logging attrs that were not rendered onto an element. Your {velog}"
205206 + " command must not be wrapping an element, this is undefined behavior." );
Original file line number Diff line number Diff line change @@ -55,6 +55,13 @@ public static Builder builder() {
5555
5656 abstract boolean hasAnchorAttributes ();
5757
58+ public boolean hasOverlappingAttributes (LoggingAttrs other ) {
59+ if (other == null ) {
60+ return false ;
61+ }
62+ return attrs ().keySet ().stream ().anyMatch (other .attrs ()::containsKey );
63+ }
64+
5865 /** Writes the attributes to the output appendable. */
5966 public void writeTo (boolean isAnchorTag , Appendable outputAppendable ) throws IOException {
6067 if (hasAnchorAttributes () && !isAnchorTag ) {
You can’t perform that action at this time.
0 commit comments