Skip to content

Commit 49fdfd6

Browse files
committed
XWIKI-20291: Improved translations of logging administration
1 parent 3376f78 commit 49fdfd6

File tree

8 files changed

+409
-15
lines changed

8 files changed

+409
-15
lines changed

xwiki-platform-core/xwiki-platform-logging/xwiki-platform-logging-script/pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,26 @@
6262
<scope>test</scope>
6363
</dependency>
6464
</dependencies>
65+
<build>
66+
<plugins>
67+
<plugin>
68+
<groupId>org.apache.maven.plugins</groupId>
69+
<artifactId>maven-jar-plugin</artifactId>
70+
<executions>
71+
<execution>
72+
<id>test-jar</id>
73+
<goals>
74+
<goal>test-jar</goal>
75+
</goals>
76+
<configuration>
77+
<includes>
78+
<include>**/LoggingScriptServiceComponentList.class</include>
79+
<include>**/NullLoggerManager.class</include>
80+
</includes>
81+
</configuration>
82+
</execution>
83+
</executions>
84+
</plugin>
85+
</plugins>
86+
</build>
6587
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.logging;
21+
22+
import java.lang.annotation.Documented;
23+
import java.lang.annotation.Inherited;
24+
import java.lang.annotation.Retention;
25+
import java.lang.annotation.Target;
26+
27+
import org.xwiki.logging.script.LoggingScriptService;
28+
import org.xwiki.test.annotation.ComponentList;
29+
30+
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
31+
import static java.lang.annotation.ElementType.METHOD;
32+
import static java.lang.annotation.ElementType.TYPE;
33+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
34+
35+
/**
36+
* Component list for {@link LoggingScriptService}.
37+
*
38+
* @version $Id$
39+
* @since 13.10.11
40+
* @since 14.4.7
41+
* @since 14.10RC1
42+
*/
43+
@Documented
44+
@Retention(RUNTIME)
45+
@Target({ TYPE, METHOD, ANNOTATION_TYPE })
46+
@ComponentList({
47+
LoggingScriptService.class,
48+
NullLoggerManager.class
49+
})
50+
@Inherited
51+
public @interface LoggingScriptServiceComponentList
52+
{
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* See the NOTICE file distributed with this work for additional
3+
* information regarding copyright ownership.
4+
*
5+
* This is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU Lesser General Public License as
7+
* published by the Free Software Foundation; either version 2.1 of
8+
* the License, or (at your option) any later version.
9+
*
10+
* This software is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this software; if not, write to the Free
17+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19+
*/
20+
package org.xwiki.logging;
21+
22+
import java.util.Collection;
23+
24+
import org.slf4j.Logger;
25+
import org.xwiki.observation.EventListener;
26+
27+
/**
28+
* Null logger manager, to be overridden if need be.
29+
*
30+
* @version $Id$
31+
* @since 13.10.11
32+
* @since 14.4.7
33+
* @since 14.10RC1
34+
*/
35+
public class NullLoggerManager implements LoggerManager
36+
{
37+
@Override
38+
public void pushLogListener(EventListener listener)
39+
{
40+
41+
}
42+
43+
@Override
44+
public EventListener popLogListener()
45+
{
46+
return null;
47+
}
48+
49+
@Override
50+
public void setLoggerLevel(String loggerName, LogLevel level)
51+
{
52+
53+
}
54+
55+
@Override
56+
public LogLevel getLoggerLevel(String loggerName)
57+
{
58+
return null;
59+
}
60+
61+
@Override
62+
public Collection<Logger> getLoggers()
63+
{
64+
return null;
65+
}
66+
}

xwiki-platform-core/xwiki-platform-logging/xwiki-platform-logging-ui/pom.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,36 @@
8080
<version>${project.version}</version>
8181
<scope>runtime</scope>
8282
</dependency>
83+
<!-- Test dependencies. -->
84+
<dependency>
85+
<groupId>org.xwiki.platform</groupId>
86+
<artifactId>xwiki-platform-test-page</artifactId>
87+
<version>${project.version}</version>
88+
<scope>test</scope>
89+
</dependency>
90+
<!-- Provides the component list for RenderingScriptService. -->
91+
<dependency>
92+
<groupId>org.xwiki.platform</groupId>
93+
<artifactId>xwiki-platform-rendering-xwiki</artifactId>
94+
<version>${project.version}</version>
95+
<type>test-jar</type>
96+
<scope>test</scope>
97+
</dependency>
98+
<!-- Provides the component list for the LiveData macro. -->
99+
<dependency>
100+
<groupId>org.xwiki.platform</groupId>
101+
<artifactId>xwiki-platform-livedata-macro</artifactId>
102+
<version>${project.version}</version>
103+
<type>test-jar</type>
104+
<scope>test</scope>
105+
</dependency>
106+
<!-- Required for LoggingScriptService. -->
107+
<dependency>
108+
<groupId>org.xwiki.platform</groupId>
109+
<artifactId>xwiki-platform-logging-script</artifactId>
110+
<version>${project.version}</version>
111+
<type>test-jar</type>
112+
<scope>test</scope>
113+
</dependency>
83114
</dependencies>
84115
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.1" encoding="UTF-8"?>
2+
3+
<!--
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This is free software; you can redistribute it and/or modify it
8+
* under the terms of the GNU Lesser General Public License as
9+
* published by the Free Software Foundation; either version 2.1 of
10+
* the License, or (at your option) any later version.
11+
*
12+
* This software is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public
18+
* License along with this software; if not, write to the Free
19+
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20+
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21+
-->
22+
23+
<xwikidoc version="1.5" reference="XWiki.Logging.Code.Translations" locale="">
24+
<web>XWiki.Logging.Code</web>
25+
<name>Translations</name>
26+
<language/>
27+
<defaultLanguage>en</defaultLanguage>
28+
<translation>0</translation>
29+
<creator>xwiki:XWiki.Admin</creator>
30+
<parent>WebHome</parent>
31+
<author>xwiki:XWiki.Admin</author>
32+
<contentAuthor>xwiki:XWiki.Admin</contentAuthor>
33+
<version>1.1</version>
34+
<title>Translations</title>
35+
<comment/>
36+
<minorEdit>false</minorEdit>
37+
<syntaxId>plain/1.0</syntaxId>
38+
<hidden>true</hidden>
39+
<content>logging.admin.unsetLevel.success=Logger "{0}" level has been unset.
40+
logging.admin.setLevel.success=Logger "{0}" level has been set to "{1}".
41+
logging.admin.setLevel.error=Failed to set log level: the logger "{0}" doesn't exist.</content>
42+
<object>
43+
<name>XWiki.Logging.Code.Translations</name>
44+
<number>0</number>
45+
<className>XWiki.TranslationDocumentClass</className>
46+
<guid>fc29bfac-011a-4573-80ba-3f5713f1e847</guid>
47+
<class>
48+
<name>XWiki.TranslationDocumentClass</name>
49+
<customClass/>
50+
<customMapping/>
51+
<defaultViewSheet/>
52+
<defaultEditSheet/>
53+
<defaultWeb/>
54+
<nameField/>
55+
<validationScript/>
56+
<scope>
57+
<cache>0</cache>
58+
<disabled>0</disabled>
59+
<displayType>select</displayType>
60+
<freeText>forbidden</freeText>
61+
<largeStorage>0</largeStorage>
62+
<multiSelect>0</multiSelect>
63+
<name>scope</name>
64+
<number>1</number>
65+
<prettyName>Scope</prettyName>
66+
<relationalStorage>0</relationalStorage>
67+
<separator> </separator>
68+
<separators>|, </separators>
69+
<size>1</size>
70+
<unmodifiable>0</unmodifiable>
71+
<values>GLOBAL|WIKI|USER|ON_DEMAND</values>
72+
<classType>com.xpn.xwiki.objects.classes.StaticListClass</classType>
73+
</scope>
74+
</class>
75+
<property>
76+
<scope>WIKI</scope>
77+
</property>
78+
</object>
79+
</xwikidoc>

xwiki-platform-core/xwiki-platform-logging/xwiki-platform-logging-ui/src/main/resources/XWiki/LoggingAdmin.xml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,28 @@
4444
##
4545
## Setting the logger level if button has been pressed ##
4646
##
47-
#if ($request.loggeraction_set &amp;&amp; $request.logger_name &amp;&amp; $xwiki.hasAccessLevel('programming'))
47+
#set ($loggerName = $request.logger_name)
48+
#set ($loggerNameEscaped = $services.rendering.escape($escapetool.java($loggerName), 'xwiki/2.1'))
49+
#set ($loggerLevel = $request.logger_level)
50+
#set ($loggerLevelEscaped = $services.rendering.escape($escapetool.java($loggerLevel), 'xwiki/2.1'))
51+
#if ($request.loggeraction_set &amp;&amp; $loggerName &amp;&amp; $xwiki.hasAccessLevel('programming'))
4852
#set($logger_list = $logging.getLevels())
49-
#if ($!logger_list.containsKey($request.logger_name))
53+
#if ($!logger_list.containsKey($loggerName))
5054
#if ($request.logger_level == '')
51-
{{success}}Logger ${request.logger_name} level has been unset.{{/success}}
52-
#set($void = $logging.setLevel($request.logger_name, $null))
55+
{{success}}
56+
{{translation key='logging.admin.unsetLevel.success' parameters="~"${loggerNameEscaped}~""/}}
57+
{{/success}}
58+
#set($void = $logging.setLevel($loggerName, $null))
5359
#else
54-
{{success}}Logger ${request.logger_name} level has been set to ${request.logger_level}.{{/success}}
55-
#set($void = $logging.setLevel($request.logger_name, $request.logger_level))
60+
{{success}}
61+
{{translation key='logging.admin.setLevel.success'
62+
parameters="~"${loggerNameEscaped}~",~"${loggerLevelEscaped}~""/}}
63+
{{/success}}
64+
#set($void = $logging.setLevel($loggerName, $request.logger_level))
5665
#end
5766
#else
58-
{{error}}Failed to set log level: the logger "$request.logger_name" doesn't exist.{{/error}}
67+
{{error}}{{translation key='logging.admin.setLevel.error' parameters="~"${loggerNameEscaped}~""/}}{{/error}}
5968
#end
60-
6169
#end
6270
##
6371
## Live Data
@@ -77,6 +85,7 @@
7785
'filterable': false
7886
}))
7987
#end
88+
8089
{{liveData
8190
id="logging"
8291
properties="$stringtool.join($properties, ',')"

0 commit comments

Comments
 (0)