Skip to content

Package: LayoutLoggerVisitor$Level$2

LayoutLoggerVisitor$Level$2

nameinstructionbranchcomplexitylinemethod
log(Logger, String, Object, Object)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
{...}
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
7: * %%
8: * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: *
24: * *********************************************************************************************************************
25: * #L%
26: */
27: package it.tidalwave.northernwind.frontend.impl.ui;
28:
29: import javax.annotation.Nonnull;
30: import javax.annotation.concurrent.NotThreadSafe;
31: import org.slf4j.Logger;
32: import it.tidalwave.role.Composite;
33: import it.tidalwave.northernwind.frontend.ui.Layout;
34: import lombok.RequiredArgsConstructor;
35: import lombok.extern.slf4j.Slf4j;
36:
37: /***********************************************************************************************************************
38: *
39: * @author Fabrizio Giudici
40: *
41: **********************************************************************************************************************/
42: @NotThreadSafe @RequiredArgsConstructor @Slf4j
43: public class LayoutLoggerVisitor implements Composite.Visitor<Layout, Object>
44: {
45: public static enum Level
46: {
47: DEBUG
48: {
49: @Override
50: protected void log (@Nonnull final Logger log,
51: @Nonnull final String template,
52: @Nonnull final Object arg1,
53: @Nonnull final Object arg2)
54: {
55: log.debug(template, arg1, arg2);
56: }
57: },
58: INFO
59: {
60: @Override
61: protected void log (@Nonnull final Logger log,
62: @Nonnull final String template,
63: @Nonnull final Object arg1,
64: @Nonnull final Object arg2)
65: {
66: log.info(template, arg1, arg2);
67: }
68: };
69:
70: protected abstract void log (@Nonnull Logger log,
71: @Nonnull String template,
72: @Nonnull Object arg1,
73: @Nonnull Object arg2);
74: }
75:
76: private static final String SPACES = " ";
77:
78: private int indent;
79:
80: @Nonnull
81: private final Level logLevel;
82:
83: @Override
84: public void preVisit (@Nonnull final Layout layout)
85: {
86: logLevel.log(log, "{}{}", SPACES.substring(0, indent++ * 2), layout);
87: }
88:
89: @Override
90: public void postVisit (@Nonnull final Layout layout)
91: {
92: indent--;
93: }
94: }