Example usage for java.util.logging Logger log

List of usage examples for java.util.logging Logger log

Introduction

In this page you can find the example usage for java.util.logging Logger log.

Prototype

public void log(Level level, Supplier<String> msgSupplier) 

Source Link

Document

Log a message, which is only to be constructed if the logging level is such that the message will actually be logged.

Usage

From source file:nl.strohalm.cyclos.utils.logging.LoggingHandlerImpl.java

@Override
public void logSchedulingTrace(final Calendar hour, final long timeTaken) {
    final Logger logger = getScheduledTaskLogger();
    final Level level = ScheduledTaskLevel.INFO.getLevel();
    if (logger.isLoggable(level)) {
        final MathContext mathContext = settingsService.getLocalSettings().getMathContext();
        final String formattedTime = settingsService.getLocalSettings().getNumberConverter()
                .toString(new BigDecimal(timeTaken).divide(new BigDecimal(1000), mathContext));
        try {//from  w w w.ja  v a2 s .  c om
            logger.log(level, String.format("Scheduled tasks for hour %s ran on %s seconds",
                    FormatObject.formatObject(hour), formattedTime));
        } catch (final Exception e) {
            System.out.println(
                    "Error generating log on " + settingsService.getLogSettings().getScheduledTaskFile());
        }
    }
}

From source file:nl.strohalm.cyclos.utils.logging.LoggingHandlerImpl.java

@Override
public void logScheduledTaskTrace(final String taskName, final Calendar hour, final long timeTaken) {
    final Logger logger = getScheduledTaskLogger();
    final Level level = ScheduledTaskLevel.DETAILED.getLevel();
    if (logger.isLoggable(level)) {
        final MathContext mathContext = settingsService.getLocalSettings().getMathContext();
        final String formattedTime = settingsService.getLocalSettings().getNumberConverter()
                .toString(new BigDecimal(timeTaken).divide(new BigDecimal(1000), mathContext));
        try {/*from   w w w .j  av a 2  s  . c o m*/
            logger.log(level, String.format("Scheduled task '%s' for hour %s ran on %s seconds", taskName,
                    FormatObject.formatObject(hour), formattedTime));
        } catch (final Exception e) {
            System.out.println(
                    "Error generating log on " + settingsService.getLogSettings().getScheduledTaskFile());
        }
    }
}

From source file:nl.strohalm.cyclos.utils.logging.LoggingHandler.java

/**
 * Logs an scheduling group execution//  w ww  .j  a v a 2s.  c o m
 * @param time The milliseconds the scheduling took to run
 */
public void logSchedulingTrace(final long time) {
    final Logger logger = getScheduledTaskLogger();
    final Level level = ScheduledTaskLevel.INFO.getLevel();
    if (logger.isLoggable(level)) {
        final MathContext mathContext = settingsService.getLocalSettings().getMathContext();
        final String formattedTime = settingsService.getLocalSettings().getNumberConverter()
                .toString(new BigDecimal(time).divide(new BigDecimal(1000), mathContext));
        try {
            logger.log(level, String.format("Scheduled tasks ran on %s seconds", formattedTime));
        } catch (final Exception e) {
            System.out.println(
                    "Error generating log on " + settingsService.getLogSettings().getScheduledTaskFile());
        }
    }
}

From source file:edu.emory.cci.aiw.i2b2etl.dest.I2b2QueryResultsHandler.java

private void executePreHook() throws SQLException {
    Logger logger = I2b2ETLUtil.logger();
    logger.log(Level.INFO, "Executing pre-hook");
    try (Connection conn = openDataDatabaseConnection();
            CallableStatement stmt = conn.prepareCall("{call EUREKA.EK_PRE_HOOK()}")) {
        stmt.execute();// w w w .  j av a2 s .c om
        logger.log(Level.INFO, "Pre-hook executed successfully");
    }
}

From source file:edu.emory.cci.aiw.i2b2etl.dest.I2b2QueryResultsHandler.java

private void executePostHook() throws SQLException {
    Logger logger = I2b2ETLUtil.logger();
    logger.log(Level.INFO, "Executing post-hook");
    try (Connection conn = openDataDatabaseConnection();
            CallableStatement stmt = conn.prepareCall("{call EUREKA.EK_POST_HOOK()}")) {
        stmt.execute();/*from www. j a  va 2  s.  c  o  m*/
        logger.log(Level.INFO, "Post-hook executed successfully");
    }
}

From source file:nl.strohalm.cyclos.utils.logging.LoggingHandler.java

/**
 * Logs a scheduled task execution/* w  w w.j a  va2  s.c o  m*/
 * @param taskName The task name
 * @param time The milliseconds the task took to run
 */
public void logScheduledTaskTrace(final String taskName, final long time) {
    final Logger logger = getScheduledTaskLogger();
    final Level level = ScheduledTaskLevel.DETAILED.getLevel();
    if (logger.isLoggable(level)) {
        final MathContext mathContext = settingsService.getLocalSettings().getMathContext();
        final String formattedTime = settingsService.getLocalSettings().getNumberConverter()
                .toString(new BigDecimal(time).divide(new BigDecimal(1000), mathContext));
        try {
            logger.log(level, String.format("Scheduled task '%s' ran on %s seconds", taskName, formattedTime));
        } catch (final Exception e) {
            System.out.println(
                    "Error generating log on " + settingsService.getLogSettings().getScheduledTaskFile());
        }
    }
}

From source file:edu.emory.cci.aiw.i2b2etl.dest.I2b2QueryResultsHandler.java

private void enableObservationFactIndexes() throws SQLException {
    if (this.query.getQueryMode() == QueryMode.REPLACE
            || !this.configuration.getSettings().getMergeOnUpdate()) {
        Logger logger = I2b2ETLUtil.logger();
        logger.log(Level.INFO, "Enabling indices on observation_fact");
        try (Connection conn = openDataDatabaseConnection();
                CallableStatement stmt = conn.prepareCall("{call EUREKA.EK_ENABLE_INDEXES()}")) {
            stmt.execute();//from  w w w .  jav a  2  s. c  o m
            logger.log(Level.INFO, "Enabled indices on observation_fact");
        }
    }
}

From source file:edu.emory.cci.aiw.i2b2etl.dest.I2b2QueryResultsHandler.java

private void disableObservationFactIndexes() throws SQLException {
    if (this.query.getQueryMode() == QueryMode.REPLACE
            || !this.configuration.getSettings().getMergeOnUpdate()) {
        Logger logger = I2b2ETLUtil.logger();
        logger.log(Level.INFO, "Disabling indices on observation_fact");
        try (Connection conn = openDataDatabaseConnection();
                CallableStatement stmt = conn.prepareCall("{call EUREKA.EK_DISABLE_INDEXES()}")) {
            //stmt.registerOutParameter(1, Types.VARCHAR);
            stmt.execute();/*from  w  w w.java  2s.  c om*/
            logger.log(Level.INFO, "Disabled indices on observation_fact");
        }
    }
}

From source file:edu.emory.cci.aiw.i2b2etl.dest.I2b2QueryResultsHandler.java

@Override
public void handleQueryResult(String keyId, List<Proposition> propositions,
        Map<Proposition, List<Proposition>> forwardDerivations,
        Map<Proposition, List<Proposition>> backwardDerivations, Map<UniqueId, Proposition> references)
        throws QueryResultsHandlerProcessingException {
    Logger logger = I2b2ETLUtil.logger();
    logger.log(Level.FINER, "Loading patient into i2b2");
    try {//from  www  .  j  ava 2s .com
        Set<Proposition> derivedPropositions = new HashSet<>();
        PatientDimension pd = null;
        for (Proposition prop : propositions) {
            if (prop.getId().equals(this.visitPropId)) {
                pd = handlePatient(pd, keyId, prop, references, forwardDerivations, backwardDerivations,
                        derivedPropositions);
            }
        }
    } catch (InvalidConceptCodeException | InvalidFactException | InvalidPatientRecordException
            | SQLException ex) {
        throw new QueryResultsHandlerProcessingException(
                "Load into i2b2 failed for query " + this.query.getName(), ex);
    }
    logger.log(Level.FINER, "Done loading patient into i2b2");
}

From source file:nl.strohalm.cyclos.utils.logging.LoggingHandlerImpl.java

/**
 * Log an account fee transfer/*w  w w . j  a  v a  2s.  c  o  m*/
 */
@Override
public void logAccountFeeInvoice(final Invoice invoice) {
    final Logger logger = getAccountFeeLogger();
    final Level level = AccountFeeLevel.DETAILED.getLevel();
    if (logger.isLoggable(level)) {
        final UnitsConverter unitsConverter = settingsService.getLocalSettings()
                .getUnitsConverter(invoice.getTransferType().getFrom().getCurrency().getPattern());
        final String message = "Sent invoice of %s from %s";
        final Object[] params = { unitsConverter.toString(invoice.getAmount()),
                invoice.getToMember().getUsername() };
        try {
            logger.log(level, String.format(message, params));
        } catch (final Exception e) {
            System.out
                    .println("Error generating log on " + settingsService.getLogSettings().getAccountFeeFile());
        }
    }
}