use of act.cli.Command in project actframework by actframework.
the class RouterAdmin method listRoutes.
@Command(name = "act.route.list, act.route.print", help = "list routes")
@PropertySpec("method,path,compactHandler")
public Object listRoutes(@Optional("list routes in tree view") boolean tree, @Optional("specify the port name") String name, @Optional("specify route filter") String q) {
final Router router = S.blank(name) ? app.router() : app.router(name);
if (S.notBlank(q)) {
if (q.contains(".") || q.contains("[") || q.contains("*")) {
// already regex
} else {
// make it a regex
q = ".*" + q + ".*";
}
}
if (tree) {
TreeNode root = new TreeNode() {
@Override
public String id() {
return "root";
}
@Override
public String label() {
return "Router";
}
@Override
public List<TreeNode> children() {
List<TreeNode> l = new ArrayList<>();
l.add(router._GET);
l.add(router._POST);
l.add(router._PUT);
l.add(router._DEL);
return l;
}
};
return S.blank(q) ? root : new FilteredTreeNode(root, TreeNodeFilter.Common.pathMatches(q));
} else {
return routeInfoList(name, q);
}
}
use of act.cli.Command in project actframework by actframework.
the class LogAdmin method setLogLevel.
@Command(name = "act.log.level.update", help = "Update LOGGER level. Valid levels are:\n\t" + "5 - fatal\n\t" + "4 - error\n\t" + "3 - warn\n\t" + "2 - info\n\t" + "1 - debug\n\t" + "0 - trace")
public String setLogLevel(@Required("specify LOGGER name") String name, @Required("specify log level") int level) {
Level lvl = convert(level);
Logger logger = LogManager.get(name);
logger.setLevel(lvl);
return S.fmt("LOGGER[%s] level set to %s", name, lvl.toString());
}
use of act.cli.Command in project actframework by actframework.
the class DaemonAdmin method status.
@Command(name = "act.daemon.status", help = "Report app daemon status")
public void status(@Required("specify daemon id") String id, CliContext context, @Provided JodaDateTimeCodec fmt) {
Daemon daemon = get(id, context);
Daemon.State state = daemon.state();
DateTime ts = daemon.timestamp();
Exception lastError = daemon.lastError();
context.println("Daemon[%s]: %s at %s", id, state, fmt.toString(ts));
if (null != lastError) {
DateTime errTs = daemon.errorTimestamp();
if (null != errTs) {
context.println("Last error: %s at %s", E.stackTrace(lastError), fmt.toString(errTs));
} else {
context.println("Last error: %s", E.stackTrace(lastError));
}
}
Map<String, Object> attributes = daemon.getAttributes();
if (!attributes.isEmpty()) {
context.println("Attributes: %s", attributes);
}
}
Aggregations