use of org.craftercms.studio.api.v1.log.Logger in project studio by craftercms.
the class L4jLogProvider method getLogger.
/**
* return a logger implementation
* @param targetClass ther target class for the logger
*/
public Logger getLogger(Class targetClass) {
Logger retLogger = null;
org.slf4j.Logger l4jLogger = org.slf4j.LoggerFactory.getLogger(targetClass);
retLogger = new LoggerImpl(l4jLogger);
return retLogger;
}
use of org.craftercms.studio.api.v1.log.Logger in project studio by craftercms.
the class DebugUtils method addDebugStack.
public static void addDebugStack(Logger logger) {
if (logger.getLevel().equals(Logger.LEVEL_DEBUG)) {
Thread thread = Thread.currentThread();
String threadName = thread.getName();
logger.debug("Thread: " + threadName);
StackTraceElement[] stackTraceElements = thread.getStackTrace();
StringBuilder sbStack = new StringBuilder();
int stackSize = (20 < stackTraceElements.length - 2) ? 20 : stackTraceElements.length;
for (int i = 2; i < stackSize + 2; i++) {
sbStack.append("\n\t").append(stackTraceElements[i].toString());
}
RequestContext context = RequestContext.getCurrent();
CronJobContext cronJobContext = CronJobContext.getCurrent();
if (context != null) {
HttpServletRequest request = context.getRequest();
String url = request.getRequestURI() + "?" + request.getQueryString();
logger.debug("Http request: " + url);
} else if (cronJobContext != null) {
logger.debug("Cron Job");
}
logger.debug("Stack trace (depth 20): " + sbStack.toString());
}
}
use of org.craftercms.studio.api.v1.log.Logger in project studio by craftercms.
the class ContentServiceImpl method getContentItemTree.
@Override
@ValidateParams
public ContentItemTO getContentItemTree(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path, @ValidateIntegerParam(name = "depth") int depth) {
logger.debug("Getting content item tree for '{}':'{}' depth '{}'", site, path, depth);
DebugUtils.addDebugStack(logger);
long startTime = System.currentTimeMillis();
boolean isPages = (path.contains(FILE_SEPARATOR + "site" + FILE_SEPARATOR + "website"));
ContentItemTO root = null;
if (isPages && contentExists(site, path + FILE_SEPARATOR + DmConstants.INDEX_FILE)) {
if (depth > 1) {
root = getContentItem(site, path + FILE_SEPARATOR + DmConstants.INDEX_FILE, depth);
} else {
root = getContentItem(site, path + FILE_SEPARATOR + DmConstants.INDEX_FILE);
}
} else {
if (depth > 1) {
root = getContentItem(site, path, depth);
} else {
root = getContentItem(site, path);
}
}
long executionTime = System.currentTimeMillis() - startTime;
logger.debug("Content item tree ['{}':'{}' depth '{}'] retrieved in '{}' milli-seconds", site, path, depth, executionTime);
return root;
}
use of org.craftercms.studio.api.v1.log.Logger in project studio by craftercms.
the class ContentServiceImpl method getContentItem.
@Override
@ValidateParams
public ContentItemTO getContentItem(@ValidateStringParam(name = "site") String site, @ValidateSecurePathParam(name = "path") String path, @ValidateIntegerParam(name = "depth") int depth) {
ContentItemTO item = null;
logger.debug("Getting content item for site '{}' path '{}' depth '{}'", site, path, depth);
DebugUtils.addDebugStack(logger);
long startTime = System.currentTimeMillis();
try {
if (contentExists(site, path)) {
// get item from cache
item = loadContentItem(site, path);
if (depth != 0) {
item = populateItemChildren(item, depth);
}
// POPULATE LOCK STATUS
populateMetadata(site, item);
// POPULATE WORKFLOW STATUS
if (!item.isFolder() || item.isContainer()) {
populateWorkflowProperties(site, item);
} else {
item.setNew(!objectStateService.isFolderLive(site, item.getUri()));
item.isNew = item.isNew();
}
} else {
item = createDummyDmContentItemForDeletedNode(site, path);
}
} catch (Exception err) {
logger.debug("error constructing item for object at site '{}' path '{}'", err, site, path);
}
long executionTime = System.currentTimeMillis() - startTime;
logger.debug("Content item from site '{}' path '{}' retrieved in '{}' milli-seconds", site, path, executionTime);
return item;
}
Aggregations