下面列出了java.util.logging.Logger#fine ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void run() {
try {
while (goOn) {
Logger l;
Logger foo = Logger.getLogger("foo");
Logger bar = Logger.getLogger("foo.bar");
for (int i=0; i < LCOUNT ; i++) {
l = Logger.getLogger("foo.bar.l"+nextLogger.incrementAndGet());
l.fine("I'm fine");
if (!goOn) break;
Thread.sleep(1);
}
}
} catch (InterruptedException | RuntimeException x ) {
fail(x);
}
}
/**
* Finds an image by ID or by tag.
* @param name an image ID or a tag name (can be null)
* @param dockerClient a Docker client (not null)
* @return an image, or null if none matched
*/
public static Image findImageByIdOrByTag( String name, DockerClient dockerClient ) {
Image image = null;
if( ! Utils.isEmptyOrWhitespaces( name )) {
Logger logger = Logger.getLogger( DockerUtils.class.getName());
List<Image> images = dockerClient.listImagesCmd().exec();
if(( image = DockerUtils.findImageById( name, images )) != null )
logger.fine( "Found a Docker image with ID " + name );
else if(( image = DockerUtils.findImageByTag( name, images )) != null )
logger.fine( "Found a Docker image with tag " + name );
}
return image;
}
public void loglevel(Level l, Logger logger, String message) {
LogTest test = LogTest.valueOf("LEV_"+l.getName());
switch(test) {
case LEV_SEVERE:
logger.severe(message);
break;
case LEV_WARNING:
logger.warning(message);
break;
case LEV_INFO:
logger.info(message);
break;
case LEV_CONFIG:
logger.config(message);
break;
case LEV_FINE:
logger.fine(message);
break;
case LEV_FINER:
logger.finer(message);
break;
case LEV_FINEST:
logger.finest(message);
break;
}
}
@Override
public void run() {
try {
while (goOn) {
Logger l;
int barcount = getBarCount();
for (int i=0; i < LCOUNT ; i++) {
l = Logger.getLogger("foo.bar"+barcount+".l"+nextLogger.incrementAndGet());
l.fine("I'm fine");
if (!goOn) break;
Thread.sleep(1);
}
}
} catch (InterruptedException | RuntimeException x ) {
fail(x);
}
}
@Test
public void test(){
Logger logger = Logger.getLogger(getClass().getName());
logger.setLevel(Level.FINEST);
UdpSyslogMessageSender messageSender = new UdpSyslogMessageSender();
SyslogHandler syslogHandler = new SyslogHandler(messageSender, Level.ALL, null);
messageSender.setSyslogServerHostname("cloudbees1.papertrailapp.com");
messageSender.setSyslogServerPort(18977);
syslogHandler.setMessageHostname("mysecretkey");
syslogHandler.setAppName("SyslogHandlerTest");
logger.addHandler(syslogHandler);
logger.fine("hello world 2");
}
@Override
public void run() {
try {
while (goOn) {
Logger l;
int barcount = getBarCount();
for (int i=0; i < LCOUNT ; i++) {
l = Logger.getLogger("foo.bar"+barcount+".l"+nextLogger.incrementAndGet());
l.fine("I'm fine");
if (!goOn) break;
Thread.sleep(1);
}
}
} catch (InterruptedException | RuntimeException x ) {
fail(x);
}
}
@Override
public void run() {
try {
while (goOn) {
Logger l;
int barcount = getBarCount();
for (int i=0; i < LCOUNT ; i++) {
l = Logger.getLogger("foo.bar"+barcount+".l"+nextLogger.incrementAndGet());
l.fine("I'm fine");
if (!goOn) break;
Thread.sleep(1);
}
}
} catch (InterruptedException | RuntimeException x ) {
fail(x);
}
}
public void loglevel(Level l, Logger logger, String message) {
LogTest test = LogTest.valueOf("LEV_"+l.getName());
switch(test) {
case LEV_SEVERE:
logger.severe(message);
break;
case LEV_WARNING:
logger.warning(message);
break;
case LEV_INFO:
logger.info(message);
break;
case LEV_CONFIG:
logger.config(message);
break;
case LEV_FINE:
logger.fine(message);
break;
case LEV_FINER:
logger.finer(message);
break;
case LEV_FINEST:
logger.finest(message);
break;
}
}
@Override
public void run() {
try {
while (goOn) {
Logger l;
int barcount = getBarCount();
for (int i=0; i < LCOUNT ; i++) {
l = Logger.getLogger("foo.bar"+barcount+".l"+nextLogger.incrementAndGet());
l.fine("I'm fine");
if (!goOn) break;
Thread.sleep(1);
}
}
} catch (InterruptedException | RuntimeException x ) {
fail(x);
}
}
/**
* Executes a command on the VM and logs the output.
* @param logger a logger (not null)
* @param command a command to execute (not null, not empty)
* @param workingDir the working directory for the command
* @param environmentVars a map containing environment variables (can be null)
* @param applicationName the roboconf application name (null if not specified)
* @param scopedInstancePath the roboconf scoped instance path (null if not specified)
* @throws IOException if a new process could not be created
* @throws InterruptedException if the new process encountered a process
*/
public static int executeCommand(
final Logger logger,
final String[] command,
final File workingDir,
final Map<String,String> environmentVars,
final String applicationName,
final String scopedInstancePath)
throws IOException, InterruptedException {
ExecutionResult result = executeCommandWithResult( logger, command, workingDir, environmentVars, applicationName, scopedInstancePath);
if( ! Utils.isEmptyOrWhitespaces( result.getNormalOutput()))
logger.fine( result.getNormalOutput());
if( ! Utils.isEmptyOrWhitespaces( result.getErrorOutput()))
logger.warning( result.getErrorOutput());
return result.getExitValue();
}
public void testEarlyPublish() throws Exception {
EarlyHandler eh = Lookup.getDefault().lookup(EarlyHandler.class);
Logger allLogger = Logger.getLogger("org.myapplication.ui.test_early"); // Copied Installer.UI_LOGGER_NAME, not to initialize Installer class.
allLogger.setLevel(Level.ALL);
allLogger.addHandler(eh);
allLogger.fine("Test Message 1");
allLogger.info("Test Message 2");
allLogger.finest("Test Message 3");
Installer installer = Installer.findObject(Installer.class, true);
installer.restored();
assertEquals("EarlyHandler turned off", Level.OFF, eh.getLevel());
allLogger.finer("Test Message 4");
List<LogRecord> logs = InstallerTest.getLogs();
assertEquals("Number of messages logged: ", 4, logs.size());
for (int i = 0; i < logs.size(); i++) {
assertEquals("Test Message "+(i+1), logs.get(i).getMessage());
}
}
@Override
public void run() {
try {
while (goOn) {
Logger l;
int barcount = getBarCount();
for (int i=0; i < LCOUNT ; i++) {
l = Logger.getLogger("foo.bar"+barcount+".l"+nextLogger.incrementAndGet());
l.fine("I'm fine");
if (!goOn) break;
Thread.sleep(1);
}
}
} catch (InterruptedException | RuntimeException x ) {
fail(x);
}
}
public void logDebug(Logger logger, String message) {
if (isAndroidLog()) {
logger.info(message);
} else {
logger.fine(message);
}
}
@Override
public synchronized void taskCancelled(ClientTask task) {
Logger logger = Logger.getLogger("lancoder");
logger.fine(String.format("Cancelled %s.%n", task));
task.getProgress().reset();
notifyAndRemove(task);
}
public void testLoadFromSubdirTheSFS() throws Exception {
Logger log = Logger.getLogger(T.class.getName());
for (int i = 0; i < 100; i++) {
log.fine("Adding " + i);
Thread.sleep(100);
}
}
@Override
public void preBlow(String path, long maxSize, boolean preAllocate)
throws IOException {
final Logger logger = ClientSharedUtils.getLogger();
if (logger != null && logger.isLoggable(Level.FINE)) {
logger.fine("DEBUG preBlow called for path = " + path);
}
if (!preAllocate || !hasFallocate()) {
super.preBlow(path, maxSize, preAllocate);
if (logger != null && logger.isLoggable(Level.FINE)) {
logger.fine("DEBUG preBlow super.preBlow 1 called for path = "
+ path);
}
return;
}
int fd = -1;
boolean unknownError = false;
try {
fd = createFD(path, 00644);
if (!isOnLocalFileSystem(path)) {
super.preBlow(path, maxSize, preAllocate);
if (logger != null && logger.isLoggable(Level.FINE)) {
logger.fine("DEBUG preBlow super.preBlow 2 called as path = "
+ path + " not on local file system");
}
if (TEST_NO_FALLOC_DIRS != null) {
TEST_NO_FALLOC_DIRS.add(path);
}
return;
}
fallocateFD(fd, 0L, maxSize);
if (TEST_CHK_FALLOC_DIRS != null) {
TEST_CHK_FALLOC_DIRS.add(path);
}
if (logger != null && logger.isLoggable(Level.FINE)) {
logger.fine("DEBUG preBlow posix_fallocate called for path = " + path
+ " and ret = 0 maxsize = " + maxSize);
}
} catch (LastErrorException le) {
if (logger != null && logger.isLoggable(Level.FINE)) {
logger.fine("DEBUG preBlow posix_fallocate called for path = " + path
+ " and ret = " + le.getErrorCode() + " maxsize = " + maxSize);
}
// check for no space left on device
if (le.getErrorCode() == ENOSPC) {
unknownError = false;
throw new IOException("Not enough space left on device");
}
else {
unknownError = true;
}
} finally {
if (fd >= 0) {
try {
close(fd);
} catch (Exception e) {
// ignore
}
}
if (unknownError) {
super.preBlow(path, maxSize, preAllocate);
if (logger != null && logger.isLoggable(Level.FINE)) {
logger.fine("DEBUG preBlow super.preBlow 3 called for path = "
+ path);
}
}
}
}
public void launch(CountDownLatch done) {
Logger log = Logger.getLogger("app_test_logger");
log.fine("Test app is launched");
done.countDown();
}
public void launch(CountDownLatch done) {
Logger log = Logger.getLogger("app_test_logger");
log.fine("Test app is launched");
done.countDown();
}
public void launch(CountDownLatch done) {
Logger log = Logger.getLogger("app_test_logger");
log.fine("Test app is launched");
done.countDown();
}
public void launch(CountDownLatch done) {
Logger log = Logger.getLogger("app_test_logger");
log.fine("Test app is launched");
done.countDown();
}