/** * Create a new log instance based on an slf4j logger for class <code>clazz</code>. * * @see org.slf4j.LoggerFactory#getLogger(Class) */ public static Log mk(Class<?> clazz) { return new Log(LoggerFactory.getLogger(clazz)); }
private static void updateCurrent() { current.set(ctxAsString()); }
private void logException(Throwable t) { log.error(t, "Error recording job incident. Log exception and move on."); }
/** Start a new unit of work. */ public void startUnitOfWork() { ctx.get().push(randomString()); updateCurrent(); }
@Override protected String process(Job job) throws Exception { log.info("Processing job %d", job.getId()); return PAYLOAD; }
public void debug(String msg, Object... args) { log(LocationAwareLogger.DEBUG_INT, null, msg, args); }
/** <code>t</code> maybe null */ private void log(int level, Throwable t, String format, Object... args) { final String msg = current.get() + format(convertCurlyBraces(format), args); if (isLocationAware) { ((LocationAwareLogger) logger).log(null, FQCN, level, msg, null, t); } else { switch (level) { case LocationAwareLogger.INFO_INT: logger.info(msg); break; case LocationAwareLogger.WARN_INT: logger.warn(msg); break; case LocationAwareLogger.ERROR_INT: logger.error(msg); break; default: Prelude.unexhaustiveMatch(); } } }
public void updated(Dictionary<String, ?> properties) throws ConfigurationException { String cronExpression; boolean enabled; unschedule(); if (properties != null) { logger.debug("Updating configuration..."); enabled = BooleanUtils.toBoolean((String) properties.get(PARAM_KEY_ENABLED)); setEnabled(enabled); logger.debug("enabled = " + enabled); cronExpression = (String) properties.get(PARAM_KEY_CRON_EXPR); if (StringUtils.isBlank(cronExpression) || !CronExpression.isValidExpression(cronExpression)) throw new ConfigurationException(PARAM_KEY_CRON_EXPR, "Cron expression must be valid"); setCronExpression(cronExpression); logger.debug("cronExpression = '" + cronExpression + "'"); try { buffer = Long.valueOf((String) properties.get(PARAM_KEY_BUFFER)); if (buffer < 0) { throw new ConfigurationException(PARAM_KEY_BUFFER, "Buffer must be 0 or greater"); } } catch (NumberFormatException e) { throw new ConfigurationException(PARAM_KEY_BUFFER, "Buffer must be a valid integer", e); } logger.debug("buffer = " + buffer); } schedule(); }
signedUrlExpiresDuration = expiration.get(); logger.debug("The property {} has been configured to expire signed URLs in {}.", INTERNAL_URL_SIGNING_DURATION_KEY, Log.getHumanReadableTimeString(signedUrlExpiresDuration)); } else { signedUrlExpiresDuration = DEFAULT_URL_SIGNING_EXPIRES_DURATION; logger.debug( "The property {} has not been configured, so the default is being used to expire signed URLs in {}.", INTERNAL_URL_SIGNING_DURATION_KEY, Log.getHumanReadableTimeString(signedUrlExpiresDuration));
/** * {@inheritDoc} * * @see org.opencastproject.workingfilerepository.api.WorkingFileRepository#delete(java.lang.String, java.lang.String) */ public boolean delete(String mediaPackageID, String mediaPackageElementID) throws IOException { File f; try { f = getFile(mediaPackageID, mediaPackageElementID); File parentDirectory = f.getParentFile(); logger.debug("Attempting to delete {}", parentDirectory.getAbsolutePath()); FileUtils.forceDelete(parentDirectory); File parentsParentDirectory = parentDirectory.getParentFile(); if (parentsParentDirectory.isDirectory() && parentsParentDirectory.list().length == 0) FileUtils.forceDelete(parentDirectory.getParentFile()); return true; } catch (NotFoundException e) { log.info("Unable to delete non existing media package element {}@{}", mediaPackageElementID, mediaPackageID); return false; } }
public void debug(String msg) { log(LocationAwareLogger.DEBUG_INT, null, msg); }
@Override public WorkflowOperationResult start(WorkflowInstance wi, JobContext ctx) throws WorkflowOperationException { final WorkflowOperationInstance woi = wi.getCurrentOperation(); final int code = option(woi.getConfiguration(OPT_CODE)).bind(Strings.toInt).getOrElse(1); final Severity severity = option(woi.getConfiguration(OPT_SEVERITY)).bind(parseEnum(Severity.FAILURE)).getOrElse(Severity.INFO); final List<Tuple<String, String>> details = Arrays.stream(ArrayUtils.nullToEmpty( StringUtils.split(woi.getConfiguration(OPT_DETAILS), ";"))) .map((opt) -> opt.split("=")) .filter((t) -> t.length == 2) .map((x) -> Tuple.tuple(x[0], x[1])) .collect(Collectors.toList()); final Map<String, String> params = Arrays.stream(ArrayUtils.nullToEmpty( StringUtils.split(woi.getConfiguration(OPT_PARAMS), ";"))) .map((opt) -> opt.split("=")) .filter((t) -> t.length == 2) .collect(Collectors.toMap(x -> x[0], x -> x[1])); log.info("Create nop job"); final Job job = nopService.nop(); log.info("Log a dummy incident with code %d", code); serviceRegistry.incident().record(job, severity, code, params, details); if (!waitForStatus(job).isSuccess()) { throw new WorkflowOperationException("Job did not complete successfully"); } else { return createResult(WorkflowOperationResult.Action.CONTINUE); } }
public void warn(Throwable t, String msg) { log(LocationAwareLogger.WARN_INT, t, msg); }
public void info(String msg) { log(LocationAwareLogger.INFO_INT, null, msg); }
public void info(String msg, Object... args) { log(LocationAwareLogger.INFO_INT, null, msg, args); }
public void warn(String msg) { log(LocationAwareLogger.WARN_INT, null, msg); }
public void warn(String msg, Object... args) { log(LocationAwareLogger.WARN_INT, null, msg, args); }
public void error(String msg) { log(LocationAwareLogger.ERROR_INT, null, msg); }
public void error(String msg, Object... args) { log(LocationAwareLogger.ERROR_INT, null, msg, args); }
public void error(Throwable t, String msg, Object... args) { log(LocationAwareLogger.ERROR_INT, t, msg, args); }