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