Commit a9540f3b authored by Liyuan Li's avatar Liyuan Li

Merge remote-tracking branch 'origin/dev' into dev

parents 196b9439 2f3101b5
......@@ -81,7 +81,7 @@ public final class Server extends BaseServer {
public static void initInMemoryLogger() {
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
final Configuration config = ctx.getConfiguration();
final StringLayout layout = PatternLayout.newBuilder().build();
final StringLayout layout = PatternLayout.newBuilder().withPattern("[%-5p]-[%d{yyyy-MM-dd HH:mm:ss}]-[%c:%L]: %m%n").build();
final Appender appender = WriterAppender.createAppender(layout, null, TAIL_LOGGER_WRITER, "InMemoryTail", true, true);
appender.start();
config.addAppender(appender);
......@@ -618,6 +618,7 @@ public final class Server extends BaseServer {
otherConsoleGroup.middlewares(consoleAdminAuthMidware::handle);
otherConsoleGroup.delete("/console/archive/unused", otherConsole::removeUnusedArchives).
delete("/console/tag/unused", otherConsole::removeUnusedTags);
otherConsoleGroup.get("/console/log", otherConsole::getLog);
final UserConsole userConsole = beanManager.getReference(UserConsole.class);
final Dispatcher.RouterGroup userConsoleGroup = Dispatcher.group();
......@@ -632,11 +633,6 @@ public final class Server extends BaseServer {
final Dispatcher.RouterGroup staticSiteConsoleGroup = Dispatcher.group();
staticSiteConsoleGroup.middlewares(consoleAdminAuthMidware::handle);
staticSiteConsoleGroup.put("/console/staticsite", staticSiteConsole::genSite);
final LogConsole logConsole = beanManager.getReference(LogConsole.class);
final Dispatcher.RouterGroup logConsoleGroup = Dispatcher.group();
logConsoleGroup.middlewares(consoleAdminAuthMidware::handle);
logConsoleGroup.get("/console/log", logConsole::getLog);
}
/**
......
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-present, b3log.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.processor.console;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.b3log.latke.http.RequestContext;
import org.b3log.latke.ioc.Singleton;
import org.b3log.solo.Server;
/**
* Log console request processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Apr 2, 2020
* @since 4.1.0
*/
@Singleton
public class LogConsole {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(LogConsole.class);
/**
* Get log.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "sc": boolean,
* "log": "log lines"
* }
* </pre>
* </p>
*
* @param context the specified request context
*/
public void getLog(final RequestContext context) {
context.renderJSON(true);
final String content = Server.TAIL_LOGGER_WRITER.toString();
context.renderJSONValue("log", content);
}
}
......@@ -26,6 +26,7 @@ import org.b3log.latke.http.renderer.JsonRenderer;
import org.b3log.latke.ioc.Inject;
import org.b3log.latke.ioc.Singleton;
import org.b3log.latke.service.LangPropsService;
import org.b3log.solo.Server;
import org.b3log.solo.service.ArchiveDateMgmtService;
import org.b3log.solo.service.TagMgmtService;
import org.json.JSONObject;
......@@ -34,7 +35,7 @@ import org.json.JSONObject;
* Other console request processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.0.0, Feb 9, 2020
* @version 2.1.0.0, Apr 2, 2020
* @since 3.4.0
*/
@Singleton
......@@ -63,6 +64,27 @@ public class OtherConsole {
@Inject
private LangPropsService langPropsService;
/**
* Get log.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "sc": boolean,
* "log": "log lines"
* }
* </pre>
* </p>
*
* @param context the specified request context
*/
public void getLog(final RequestContext context) {
context.renderJSON(true);
final String content = Server.TAIL_LOGGER_WRITER.toString();
context.renderJSONValue("log", content);
}
/**
* Removes all unused archives.
* <p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment