/** * Can be used to mark an exception as ignored. * <p> * Instead of leading a try / catch block empty, the method can be invoked. Therefore it is known, that the * exception is wanted to be ignored. Additionally, the <tt>ignoredExceptions</tt> logger can be turned on, * to still see those exceptions. * * @param t the exception to be ignored. This exception will be discarded unless the <tt>ignoredExceptions</tt> * logger is set to INFO. */ public static void ignore(Throwable t) { IGNORED_EXCEPTIONS_LOG.INFO(t); }
private static void outputThreadState() { LOG.INFO("System halted! - Thread State"); LOG.INFO(SEPARATOR_LINE); LOG.INFO("%-15s %10s %53s", "STATE", "ID", "NAME"); for (ThreadInfo info : ManagementFactory.getThreadMXBean().dumpAllThreads(false, false)) { LOG.INFO("%-15s %10s %53s", info.getThreadState().name(), info.getThreadId(), info.getThreadName()); } LOG.INFO(SEPARATOR_LINE); }
private void updateMappings() { if (updateSchema) { for (String msg : schema.createMappings()) { IndexAccess.LOG.INFO(msg); } } }
@Override public void log(String message) { Tasks.LOG.INFO(ctx.getSystemString() + ": " + message); }
private static void stopLifecycleParticipants() { LOG.INFO("Stopping lifecycles..."); LOG.INFO(SEPARATOR_LINE); for (int i = lifecycleStopParticipants.size() - 1; i >= 0; i--) { Stoppable stoppable = lifecycleStopParticipants.get(i); Future future = tasks.defaultExecutor().fork(() -> stopLifecycle(stoppable)); if (!future.await(Duration.ofSeconds(10))) { LOG.WARN("Lifecycle '%s' did not stop within 10 seconds....", stoppable.getClass().getName()); } } LOG.INFO(SEPARATOR_LINE); }
protected Schema(IndexAccess access) { this.access = access; indexPrefix = Sirius.getSettings().getString("index.prefix"); if (indexPrefix.contains("${timestamp}")) { temporaryIndexPrefix = true; indexPrefix = indexPrefix.replace("${timestamp}", String.valueOf(System.currentTimeMillis())); IndexAccess.LOG.INFO("Using unique index prefix: %s", indexPrefix); } if (Strings.isFilled(indexPrefix) && !indexPrefix.endsWith("-")) { indexPrefix = indexPrefix + "-"; } }
/** * Used to log the given message <tt>msg</tt> at <b>INFO</b> level if debug mode is enabled * ({@link sirius.kernel.Sirius#isDev()}). Otherwise the message will be logged as <b>FINE</b>. * * @param msg the message to log */ public void DEBUG_INFO(Object msg) { if (Sirius.isDev()) { INFO(msg); } else { FINE(msg); } }
@Override public void started() { if (!isEnabled()) { LOG.INFO("ElasticSearch is disabled! (index.host is not set)"); return; } index.startup(); }
private static void setupClasspath() { classpath = new Classpath(setup.getLoader(), "component.marker", customizations); classpath.getComponentRoots().forEach(url -> { LOG.INFO("Classpath: %s", url); }); }
private Translation autocreateMissingEntry(@Nonnull String property) { LOG.INFO("Non-existent translation: %s", property); Translation entry = new Translation(property); entry.setAutocreated(true); inLock(newTranslations -> { newTranslations.put(entry.getKey(), entry); }); return entry; }
private static void stopLifecycle(Stoppable lifecycle) { LOG.INFO("Stopping: %s", lifecycle.getClass().getName()); try { lifecycle.stopped(); } catch (Exception e) { Exceptions.handle() .error(e) .to(LOG) .withSystemErrorMessage("Stop of: %s failed!", lifecycle.getClass().getName()) .handle(); } }
private static void startLifecycle(Startable lifecycle) { LOG.INFO("Starting: %s", lifecycle.getClass().getName()); try { lifecycle.started(); } catch (Exception e) { Exceptions.handle() .error(e) .to(LOG) .withSystemErrorMessage("Startup of: %s failed!", lifecycle.getClass().getName()) .handle(); } }
private void createIndices(MongoDatabase db) { for (IndexDescription idx : indexDescriptions) { Watch w = Watch.start(); try { LOG.INFO("Creating indices in Mongo DB: %s", idx.getClass().getName()); idx.createIndices(db); LOG.INFO("Completed indices for: %s (%s)", idx.getClass().getName(), w.duration()); } catch (Exception t) { Exceptions.handle() .to(LOG) .error(t) .withSystemErrorMessage("Error while creating indices for '%s': %s (%s)", idx.getClass().getName()) .handle(); } } }
private DockerMachine machine() { if (machine == null) { if (Strings.isEmpty(hostIp)) { machine = DockerMachine.localMachine().build(); } else { LOG.INFO("Using hostIp: %s", hostIp); machine = new DockerMachine(hostIp, System.getenv()); } } return machine; }
@Override public void awaitTermination() { if (!isEnabled()) { LOG.INFO("ElasticSearch is disabled! (index.host is not set)"); return; } // may take longer than 10 seconds index.getSchema().dropTemporaryIndices(); // We wait until this last call before we cut the connection to the database (elasticsearch) to permit // other stopping lifecycles access until the very end... index.ready = false; index.client.close(); } }
/** * Writes a log message to the monitor. * <p> * If no monitor is available, the <tt>async</tt> logger will be used. * * @param message the message to log * @param args the parameters used to format the message (see {@link Strings#apply(String, Object...)}) */ public void log(String message, Object... args) { if (adapter != null) { adapter.log(Strings.apply(message, args)); } else { Tasks.LOG.INFO(getSystemString() + ": " + Strings.apply(message, args)); } }
private void executeAndReCreateBulk() { if (counter > 0) { IndexAccess.LOG.INFO("Executing bulk..."); BulkResponse res = bulk.execute().actionGet(); processFailures(res); } bulk = index.getClient().prepareBulk(); counter = 0; }
protected void updateStatistics(String sql, Watch w) { w.submitMicroTiming("SQL", sql); Databases.numQueries.inc(); Databases.queryDuration.addValue(w.elapsedMillis()); if (w.elapsedMillis() > Databases.getLogQueryThresholdMillis()) { Databases.numSlowQueries.inc(); DB.SLOW_DB_LOG.INFO("A slow JDBC query was executed (%s): %s\n%s", w.duration(), sql, ExecutionPoint.snapshot().toString()); } }
protected void updateStatistics(String sql, Watch w) { w.submitMicroTiming("SQL", sql); Databases.numQueries.inc(); Databases.queryDuration.addValue(w.elapsedMillis()); if (w.elapsedMillis() > Databases.getLogQueryThresholdMillis()) { Databases.numSlowQueries.inc(); DB.SLOW_DB_LOG.INFO("A slow JDBC query was executed (%s): %s\n%s", w.duration(), sql, ExecutionPoint.snapshot().toString()); } }