Example usage for java.util.logging Logger getAnonymousLogger

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

Introduction

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

Prototype

public static Logger getAnonymousLogger() 

Source Link

Document

Create an anonymous Logger.

Usage

From source file:mockit.integration.logging.LoggingIntegrationsTest.java

@Test
public void jdkLoggingShouldLogNothing() {
    Logger log1 = Logger.getAnonymousLogger();
    Logger log2 = Logger.getAnonymousLogger("bundle");
    Logger log3 = Logger.getLogger(LoggingIntegrationsTest.class.getName());
    Logger log4 = Logger.getLogger(LoggingIntegrationsTest.class.getName(), "bundle");

    assertFalse(log1.isLoggable(Level.ALL));
    log1.severe("testing that logger does nothing");
    log2.setLevel(Level.WARNING);
    log2.info("testing that logger does nothing");
    log3.warning("testing that logger does nothing");
    log4.fine("testing that logger does nothing");
    log4.finest("testing that logger does nothing");
}

From source file:ru.codeinside.gses.activiti.ftarchive.JsonFFT.java

@Override
public Field createField(String taskId, String fieldId, String name, byte[] value, PropertyNode node,
        boolean archive) {
    TMP.remove();/*  w  ww. ja  v a 2 s .  c o m*/
    Field result;
    String stringValue = "";
    try {
        if (value != null) {
            stringValue = new String(value, "UTF-8");
        }
    } catch (UnsupportedEncodingException e) {
        Logger.getAnonymousLogger().info("can't decode model!");
    }
    if (!node.isFieldWritable() || archive) {
        result = new ReadOnly(stringValue);
    } else {
        TextArea json = new TextArea();
        //      json.setColumns(10);
        json.setSizeFull();
        json.setRows(50);
        json.setImmediate(true);
        String defaultValue = StringUtils.trimToEmpty(stringValue);
        FieldHelper.setTextBufferSink(taskId, fieldId, json, true, defaultValue);
        result = json;
    }
    FieldHelper.setCommonFieldProperty(result, node.isFieldWritable() && !archive, name,
            node.isFieldRequired());
    return result;
}

From source file:net.sqs2.omr.source.config.ConfigImpl.java

public static Config createInstance(URL url) {
    try {/*from   w ww  . j  a  va 2  s  .  com*/
        Config config = (ConfigImpl) DIGESTER.parse(url);
        if (ConfigImpl.DEFAULT_INSTANCE.getVersion().equals(config.getVersion())) {
            return config;
        } else {
            Logger.getAnonymousLogger()
                    .warning("Config file version in Source Directory is old. Override default config.");
            File oldConfigFile = new File(url.getFile());
            File backupConfigFile = new File(FileUtil.getBasepath(oldConfigFile) + ".backup");
            if (!backupConfigFile.exists()) {
                oldConfigFile.renameTo(backupConfigFile);
            }
            Session session = MarkReaderSessions.get(oldConfigFile.getParentFile());
            if (session != null) {
                session.createConfigFileIfNotExists();
            }
            // TODO: GUI alert on using default config and backup config file.
            return ConfigImpl.DEFAULT_INSTANCE;
        }
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    } catch (SAXException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:org.objectpocket.util.IdSupport.java

/**
 * returns id from annotation @Id or existing id or generate random UUID.
 * //from w w w .ja  v a  2 s. c  om
 * @param obj
 * @param referenceForAnnotation
 *            when set to true the method will return a referenced
 *            representation of the id instead of the real id. This only
 *            happens for classes with custom id defined by @Id annotation.
 *            For all others the generated Id will be returned.
 * @param put
 *            an existing id here if one exists, otherwise a new might be
 *            generated
 * @return
 */
public static String getId(Object obj, boolean referenceForAnnotation, String existingId) {
    String typeName = obj.getClass().getName();
    if (!idFieldForType_ObjectsInMemory.containsKey(typeName)) {
        Field[] fields = FieldUtils.getAllFields(obj.getClass());
        for (Field field : fields) {
            if (field.isAnnotationPresent(Id.class)) {
                if (field.getType().equals(String.class)) {
                    idFieldForType_ObjectsInMemory.put(typeName, field);
                } else {
                    Logger.getAnonymousLogger().warning("@Id annotated field in class " + typeName
                            + " is not of type java.lang.String. Will generate random ids for this class.");
                }
                break;
            }
        }
        if (!idFieldForType_ObjectsInMemory.containsKey(typeName)) {
            idFieldForType_ObjectsInMemory.put(typeName, null);
        }
    }
    Field field = idFieldForType_ObjectsInMemory.get(typeName);
    if (field != null) {
        try {
            field.setAccessible(true);
            String id = (String) field.get(obj);
            if (id != null) {
                if (referenceForAnnotation) {
                    return OP_REF_STRING + field.getName();
                } else {
                    return id;
                }
            } else {
                Logger.getAnonymousLogger().warning("Id for object " + obj + " has not been set. "
                        + "Will generate random id for this class.");
            }
        } catch (IllegalAccessException e) {
            Logger.getAnonymousLogger().log(Level.WARNING, "Could not read id from class " + typeName, e);
        }
    }
    if (existingId != null) {
        return existingId;
    }
    return UUID.randomUUID().toString();
}

From source file:spout.mddb.MddbFeatureExtractorSpout.java

private synchronized PeekableScanner moveSpoutForward() throws FileNotFoundException {
    Logger.getAnonymousLogger().log(Level.INFO, "Moving spout forward...");
    return getScanner(featureFiles.size() > 0 ? featureFiles.remove() : null);
}

From source file:edu.utd.robocode.RobocodeRunner.java

public void run(String[] robots) {
    // Create the RobocodeEngine
    // IRobocodeEngine engine = new RobocodeEngine(new
    // java.io.File("C:/Robocode")); // Run from C:/Robocode
    RobocodeEngine engine = new RobocodeEngine(); // Run from current
                                                  // working directory

    // Add battle listener to our RobocodeEngine
    engine.addBattleListener(adapter);/*  ww w .  j  a  va  2  s .  co  m*/

    // Show the battles
    engine.setVisible(false);

    // Setup the battle specification

    int numberOfRounds = 5;
    BattlefieldSpecification battlefield = new BattlefieldSpecification(800, 600); // 800x600

    Logger.getAnonymousLogger().info(RobocodeEngine.getRobotsDir().toString());

    RobotSpecification[] selectedRobots = engine.getLocalRepository(StringUtils.join(robots, ','));
    // RobotSpecification[] selectedRobots = engine.getLocalRepository();
    for (RobotSpecification robot : selectedRobots) {
        System.out.print(robot.getName() + ", ");
    }
    // RobotSpecification[] selectedRobots =
    // engine.getLocalRepository("tested.robots.BattleLost,tested.robots.EnvAttacks");

    BattleSpecification battleSpec = new BattleSpecification(numberOfRounds, battlefield, selectedRobots);

    // Run our specified battle and let it run till it's over
    engine.runBattle(battleSpec, true/* wait till the battle is over */);
}

From source file:Classes.Database.java

private Database() {
    try {/*w ww .  j a  v a2  s  .  c o  m*/
        if (DatabaseConnection(url)) {
            Logger.getAnonymousLogger().log(Level.INFO, "School db connected");
        } else {
            Logger.getAnonymousLogger().log(Level.INFO, "Cannot connect to any database");
        }
    } catch (SQLException e) {
        Logger.getAnonymousLogger().log(Level.WARNING, "SQLError in Constructor: " + e.getMessage(), e);
    }
}

From source file:ste.xtest.logging.BugFreeLoggingByteArrayOutputStream.java

@Test
public void constructor_arguments() {
    ///*from ww w  . j a  v a  2  s.co  m*/
    // logger
    //
    try {
        new LoggingByteArrayOutputStream(null, Level.ALL, 1000);
        fail("missing argument validation");
    } catch (IllegalArgumentException x) {
        then(x).hasMessageContaining("logger can not be null");
    }
    Logger log = Logger.getAnonymousLogger();
    LoggingByteArrayOutputStream o = new LoggingByteArrayOutputStream(log, Level.ALL, 1000);
    then(o.getLogger()).isSameAs(log);
    log = Logger.getLogger("ste.xtest");
    o = new LoggingByteArrayOutputStream(log, Level.ALL, 1000);
    then(o.getLogger()).isSameAs(log);

    //
    // level
    //
    try {
        new LoggingByteArrayOutputStream(Logger.getAnonymousLogger(), null, 1000);
        fail("missing argument validation");
    } catch (IllegalArgumentException x) {
        then(x).hasMessageContaining("level can not be null");
    }
    o = new LoggingByteArrayOutputStream(log, Level.ALL, 1000);
    then(o.getLevel()).isSameAs(Level.ALL);
    o = new LoggingByteArrayOutputStream(log, Level.INFO, 1000);
    then(o.getLevel()).isSameAs(Level.INFO);

    //
    // maxBytes
    //
    try {
        new LoggingByteArrayOutputStream(Logger.getAnonymousLogger(), Level.ALL, -1);
        fail("missing argument validation");
    } catch (IllegalArgumentException x) {
        then(x).hasMessageContaining("maxBytes can not be negative");
    }
    o = new LoggingByteArrayOutputStream(log, Level.ALL, 1);
    then(o.getMaxBytes()).isEqualTo(1);
}

From source file:org.ambud.marauder.sink.MarauderTitanSink.java

@Override
public Status process() throws EventDeliveryException {
    Status status = Status.READY;/*from   w  w w .  j  a v  a2  s .  c om*/
    Transaction transaction = getChannel().getTransaction();
    transaction.begin();
    for (int i = 0; i < batchSize; i++) {
        Event event = getChannel().take();
        if (event != null) {
            storeEvent(event);
            total++;
        }
    }
    Logger.getAnonymousLogger().info("committed:" + total);
    g.commit();
    transaction.commit();
    transaction.close();
    return status;
}

From source file:com.dclab.preparation.ReadTest.java

public void dig(File folder) {
    File[] files = folder.listFiles();
    Logger.getAnonymousLogger().info("OPENING folder " + folder.getName());
    Map<Boolean, List<File>> isZip = Arrays.stream(files)
            .collect(Collectors.partitioningBy((f -> f.getName().endsWith("zip"))));
    Map<Boolean, List<File>> isFolder = isZip.get(false).stream()
            .collect(Collectors.partitioningBy(f -> f.isDirectory()));
    isFolder.get(false).stream().filter(y -> y.getName().endsWith("xml")).forEach(this::scanFile);
    isFolder.get(true).stream().forEach(this::dig);
    isZip.get(true).stream().forEach(z -> {
        try {/* w ww .j  a  v a2 s.c o  m*/
            ZipFile zipFile = new ZipFile(z);
            zipFile.stream().forEach(ze -> {
                try {
                    String s = handleZip(zipFile, ze);
                    if (s != null) {
                        printLine(s);
                    }
                } catch (IOException ex) {
                    Logger.getLogger(ReadTest.class.getName()).log(Level.SEVERE, null, ex);
                }
            });
        } catch (IOException ex) {
            Logger.getLogger(ReadTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    });

}