Java Code Examples for org.slf4j.Logger.debug()

The following are Jave code examples for showing how to use debug() of the org.slf4j.Logger class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: lams   File: DefaultBootstrap.java   View Source Code Vote up 7 votes
/**
 * Initializes the OWASPI ESAPI library.
 */
protected static void initializeESAPI() {
    Logger log = getLogger();
    String systemPropertyKey = "org.owasp.esapi.SecurityConfiguration";
    String opensamlConfigImpl = ESAPISecurityConfig.class.getName();
    
    String currentValue = System.getProperty(systemPropertyKey);
    if (currentValue == null || currentValue.isEmpty()) {
        log.debug("Setting ESAPI SecurityConfiguration impl to OpenSAML internal class: {}", opensamlConfigImpl);
        System.setProperty(systemPropertyKey, opensamlConfigImpl);
        // We still need to call ESAPI.initialize() despite setting the system property, b/c within the ESAPI class
        // the property is only evaluated once in a static initializer and stored. The initialize method however
        // does overwrite the statically-set value from the system property. But still set the system property for 
        // consistency, so other callers can see what has been set.
        ESAPI.initialize(opensamlConfigImpl);
    } else {
        log.debug("ESAPI SecurityConfiguration impl was already set non-null and non-empty via system property, leaving existing value in place: {}",
                currentValue);
    }
}
 
Example 2
Project: iTAP-controller   File: ActionUtils.java   View Source Code Vote up 6 votes
/**
 * This is out of date and should be replaced with the built-in parser of MacAddress
 * @param n
 * @param actionToDecode
 * @param log
 * @return
 */
private static byte[] get_mac_addr(Matcher n, String actionToDecode, Logger log) {
	byte[] macaddr = new byte[6];     
	for (int i=0; i<6; i++) {
		if (n.group(i+1) != null) {
			try {
				macaddr[i] = get_byte("0x" + n.group(i+1));
			}
			catch (NumberFormatException e) {
				log.debug("Invalid src-mac in: '{}' (error ignored)", actionToDecode);
				return null;
			}
		}
		else { 
			log.debug("Invalid src-mac in: '{}' (null, error ignored)", actionToDecode);
			return null;
		}
	}  
	return macaddr;
}
 
Example 3
Project: lams   File: SigningUtil.java   View Source Code Vote up 6 votes
/**
 * Compute the Message Authentication Code (MAC) value over the supplied input.
 * 
 * It is up to the caller to ensure that the specified algorithm ID is consistent with the type of signing key
 * supplied.
 * 
 * @param signingKey the key with which to compute the MAC
 * @param jcaAlgorithmID the Java JCA algorithm ID to use
 * @param input the input over which to compute the MAC
 * @return the computed MAC value
 * @throws SecurityException thrown if the MAC computation results in an error
 */
public static byte[] signMAC(Key signingKey, String jcaAlgorithmID, byte[] input) throws SecurityException {
    Logger log = getLogger();
    log.debug("Computing MAC over input using key of type {} and JCA algorithm ID {}", signingKey.getAlgorithm(),
            jcaAlgorithmID);

    try {
        Mac mac = Mac.getInstance(jcaAlgorithmID);
        mac.init(signingKey);
        mac.update(input);
        byte[] rawMAC = mac.doFinal();
        log.debug("Computed MAC: {}", new String(Hex.encode(rawMAC)));
        return rawMAC;
    } catch (GeneralSecurityException e) {
        log.error("Error during MAC generation", e);
        throw new SecurityException("Error during MAC generation", e);
    }
}
 
Example 4
Project: vars-annotation   File: ActiveAppPinger.java   View Source Code Vote up 6 votes
public static boolean ping(int port, final String expectedMsg) {
    boolean beaconExists = false;
    try {
        Socket socket = new Socket("localhost", port);
        final BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        final OutputStream output = socket.getOutputStream();
        output.write("ping\n".getBytes());
        String response = reader.readLine();
        beaconExists = response.equals(expectedMsg);
        socket.close();
    }
    catch (Exception e) {
        Logger log = LoggerFactory.getLogger(ActiveAppPinger.class);
        if (log.isDebugEnabled()) {
            log.debug("Failed to connect to port " + port, e);
        }
    }
    return beaconExists;

}
 
Example 5
Project: iTAP-controller   File: InstructionUtils.java   View Source Code Vote up 6 votes
/**
 * Convert the string representation of an OFInstructionClearActions to
 * an OFInstructionClearActions. The instruction will be set within the
 * OFFlowMod.Builder provided. Notice nothing is returned, but the
 * side effect is the addition of an instruction in the OFFlowMod.Builder.
 * @param fmb; The FMB in which to append the new instruction
 * @param instStr; The string to parse the instruction from
 * @param log
 */
public static void clearActionsFromString(OFFlowMod.Builder fmb, String inst, Logger log) {

	if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
		log.error("Clear Actions Instruction not supported in OpenFlow 1.0");
		return;
	}

	if (inst != null && inst.trim().isEmpty()) { /* Allow the empty string, since this is what specifies clear (i.e. key clear does not have any defined values). */
		OFInstructionClearActions i = OFFactories.getFactory(fmb.getVersion()).instructions().clearActions();
		log.debug("Appending ClearActions instruction: {}", i);
		appendInstruction(fmb, i);
		log.debug("All instructions after append: {}", fmb.getInstructions());		
	} else {
		log.error("Got non-empty or null string, but ClearActions should not have any String sub-fields: {}", inst);
	}
}
 
Example 6
Project: OftenPorter   File: MainMixinLoop1.java   View Source Code Vote up 6 votes
public static void main(String[] args) {
    /**
     * 1.测试{@linkplain cn.xishan.oftenporter.porter.core.annotation.Mixin},自己混入自己
     */
    final Logger logger = LoggerFactory.getLogger(MainMixinLoop1.class);

    LocalMain localMain = new LocalMain(true, new PName("P1"), "utf-8");

    // 进行配置
    PorterConf conf = localMain.newPorterConf();
    conf.setContextName("MainMixinLoop1");
    conf.getSeekPackages().addClassPorter(RootPorter.class);
    localMain.startOne(conf);
    logger.debug("****************************************************");


    logger.debug("****************************************************");
    localMain.destroyAll();

}
 
Example 7
Project: OftenPorter   File: MainMixinLoop2.java   View Source Code Vote up 6 votes
public static void main(String[] args) {
    /**
     * 1.测试{@linkplain cn.xishan.oftenporter.porter.core.annotation.Mixin},自己混入自己
     */
    final Logger logger = LoggerFactory.getLogger(MainMixinLoop2.class);

    LocalMain localMain = new LocalMain(true, new PName("P1"), "utf-8");

    // 进行配置
    PorterConf conf = localMain.newPorterConf();
    conf.setContextName("MainMixinLoop2");
    conf.getSeekPackages().addClassPorter(Root2Porter.class);
    localMain.startOne(conf);
    logger.debug("****************************************************");


    logger.debug("****************************************************");
    localMain.destroyAll();

}
 
Example 8
Project: nifi-registry   File: OSUtils.java   View Source Code Vote up 6 votes
/**
 * @param process NiFi Process Reference
 * @param logger  Logger Reference for Debug
 * @return        Returns pid or null in-case pid could not be determined
 * This method takes {@link Process} and {@link Logger} and returns
 * the platform specific ProcessId for Unix like systems, a.k.a <b>pid</b>
 * In-case it fails to determine the pid, it will return Null.
 * Purpose for the Logger is to log any interaction for debugging.
 */
private static Long getUnicesPid(final Process process, final Logger logger) {
    try {
        final Class<?> procClass = process.getClass();
        final Field pidField = procClass.getDeclaredField("pid");
        pidField.setAccessible(true);
        final Object pidObject = pidField.get(process);

        logger.debug("PID Object = {}", pidObject);

        if (pidObject instanceof Number) {
            return ((Number) pidObject).longValue();
        }
        return null;
    } catch (final IllegalAccessException | NoSuchFieldException nsfe) {
        logger.debug("Could not find PID for child process due to {}", nsfe);
        return null;
    }
}
 
Example 9
Project: openhab-tado   File: TadoApiClientFactory.java   View Source Code Vote up 5 votes
private void configureLogging(ApiClient apiClient) {
    // Add logging interceptor to HTTP Client if Debug is enabled. Make it configurable?
    Logger logger = LoggerFactory.getLogger(PUBLICApi.class);
    if (logger.isDebugEnabled()) {
        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
            @Override
            public void log(String msg) {
                logger.debug(msg);
            }
        });
        loggingInterceptor.setLevel(Level.BODY);
        apiClient.getOkBuilder().addNetworkInterceptor(loggingInterceptor);
    }
}
 
Example 10
Project: nifi-registry   File: RunNiFiRegistry.java   View Source Code Vote up 5 votes
private void killProcessTree(final String pid, final Logger logger) throws IOException {
    logger.debug("Killing Process Tree for PID {}", pid);

    final List<String> children = getChildProcesses(pid);
    logger.debug("Children of PID {}: {}", new Object[]{pid, children});

    for (final String childPid : children) {
        killProcessTree(childPid, logger);
    }

    Runtime.getRuntime().exec(new String[]{"kill", "-9", pid});
}
 
Example 11
Project: aws-sdk-java-v2   File: IoUtils.java   View Source Code Vote up 5 votes
/**
 * Closes the given Closeable quietly.
 * @param is the given closeable
 * @param log logger used to log any failure should the close fail
 */
public static void closeQuietly(AutoCloseable is, Logger log) {
    if (is != null) {
        try {
            is.close();
        } catch (Exception ex) {
            Logger logger = log == null ? DEFAULT_LOG : log;
            if (logger.isDebugEnabled()) {
                logger.debug("Ignore failure in closing the Closeable", ex);
            }
        }
    }
}
 
Example 12
Project: fresco_floodlight   File: InstructionUtils.java   View Source Code Vote up 5 votes
/**
 * Convert the string representation of an OFInstructionApplyActions to
 * an OFInstructionApplyActions. The instruction will be set within the
 * OFFlowMod.Builder provided. Notice nothing is returned, but the
 * side effect is the addition of an instruction in the OFFlowMod.Builder.
 * @param fmb; The FMB in which to append the new instruction
 * @param instStr; The string to parse the instruction from
 * @param log
 */
public static void applyActionsFromString(OFFlowMod.Builder fmb, String inst, Logger log) {

	if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
		log.error("Apply Actions Instruction not supported in OpenFlow 1.0");
		return;
	}

	OFFlowMod.Builder tmpFmb = OFFactories.getFactory(fmb.getVersion()).buildFlowModify();
	OFInstructionApplyActions.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildApplyActions();
	ActionUtils.fromString(tmpFmb, inst, log);
	ib.setActions(tmpFmb.getActions());
	log.debug("Appending ApplyActions instruction: {}", ib.build());
	appendInstruction(fmb, ib.build());
	log.debug("All instructions after append: {}", fmb.getInstructions());	}
 
Example 13
Project: nifi-registry   File: RunNiFiRegistry.java   View Source Code Vote up 5 votes
private boolean isProcessRunning(final String pid, final Logger logger) {
    try {
        // We use the "ps" command to check if the process is still running.
        final ProcessBuilder builder = new ProcessBuilder();

        builder.command("ps", "-p", pid);
        final Process proc = builder.start();

        // Look for the pid in the output of the 'ps' command.
        boolean running = false;
        String line;
        try (final InputStream in = proc.getInputStream();
             final Reader streamReader = new InputStreamReader(in);
             final BufferedReader reader = new BufferedReader(streamReader)) {

            while ((line = reader.readLine()) != null) {
                if (line.trim().startsWith(pid)) {
                    running = true;
                }
            }
        }

        // If output of the ps command had our PID, the process is running.
        if (running) {
            logger.debug("Process with PID {} is running", pid);
        } else {
            logger.debug("Process with PID {} is not running", pid);
        }

        return running;
    } catch (final IOException ioe) {
        System.err.println("Failed to determine if Process " + pid + " is running; assuming that it is not");
        return false;
    }
}
 
Example 14
Project: mzzb-server   File: AutoRunConfig.java   View Source Code Vote up 5 votes
private void fetchSakuraSpeedData(int retry) {
    Logger logger = LoggerFactory.getLogger(AutoRunConfig.class);
    if (retry == 0) {
        if (logger.isWarnEnabled()) {
            logger.warn("fetching sakura speed data failed");
        }
    } else {
        if (logger.isInfoEnabled()) {
            logger.info("fetching sakura speed data ({})", retry);
        }
        try {
            sakuraSpeedSpider.fetch();
        } catch (IOException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("fetching sakura speed data throw an error", e);
            }
            if (retry > 0) {
                fetchSakuraSpeedData(retry - 1);
            } else {
                return;
            }
        }
        if (logger.isInfoEnabled()) {
            logger.info("fetched sakura speed data ({})", retry);
        }
    }
}
 
Example 15
Project: iTAP-controller   File: ActionUtils.java   View Source Code Vote up 5 votes
/**
 * Parse string and numerical port representations.
 * The key and delimiter for the action should be omitted, and only the
 * data should be presented to this decoder. Data can be any signed integer
 * as a string or the strings 'controller', 'local', 'ingress-port', 'normal',
 * or 'flood'.
 * @param actionToDecode; The action as a string to decode
 * @param version; The OF version to create the action for
 * @param log
 * @return
 */
@LogMessageDoc(level="ERROR",
		message="Invalid subaction: '{subaction}'",
		explanation="A static flow entry contained an invalid subaction",
		recommendation=LogMessageDoc.REPORT_CONTROLLER_BUG)
private static OFActionOutput decode_output(String actionToDecode, OFVersion version, Logger log) {
	Matcher n = Pattern.compile("((all)|(controller)|(local)|(ingress-port)|(normal)|(flood))").matcher(actionToDecode);
	OFActionOutput.Builder ab = OFFactories.getFactory(version).actions().buildOutput();
	OFPort port = OFPort.ANY;
	if (n.matches()) {
		if (n.group(1) != null && n.group(1).equals("all")) 
			port = OFPort.ALL;
		else if (n.group(1) != null && n.group(1).equals("controller"))
			port = OFPort.CONTROLLER;
		else if (n.group(1) != null && n.group(1).equals("local"))
			port = OFPort.LOCAL;
		else if (n.group(1) != null && n.group(1).equals("ingress-port"))
			port = OFPort.IN_PORT;
		else if (n.group(1) != null && n.group(1).equals("normal"))
			port = OFPort.NORMAL;
		else if (n.group(1) != null && n.group(1).equals("flood"))
			port = OFPort.FLOOD;
		ab.setPort(port);
		ab.setMaxLen(Integer.MAX_VALUE);
		log.debug("action {}", ab.build());
		return ab.build();
	}
	else {
		try {
			port = OFPort.of(Integer.parseInt(actionToDecode));
			ab.setPort(port);
			ab.setMaxLen(Integer.MAX_VALUE);
			return ab.build();
		} catch (NumberFormatException e) {
			log.error("Could not parse Integer port: '{}'", actionToDecode);
			return null;
		}
	}
}
 
Example 16
Project: fresco_floodlight   File: InstructionUtils.java   View Source Code Vote up 4 votes
/**
 * Convert the string representation of an OFInstructionMetadata to
 * an OFInstructionMetadata. The instruction will be set within the
 * OFFlowMod.Builder provided. Notice nothing is returned, but the
 * side effect is the addition of an instruction in the OFFlowMod.Builder.
 * @param fmb; The FMB in which to append the new instruction
 * @param instStr; The string to parse the instruction from
 * @param log
 */
public static void writeMetadataFromString(OFFlowMod.Builder fmb, String inst, Logger log) {
	if (inst == null || inst.equals("")) {
		return;
	}

	if (fmb.getVersion().compareTo(OFVersion.OF_11) < 0) {
		log.error("Write Metadata Instruction not supported in OpenFlow 1.0");
		return;
	}

	OFInstructionWriteMetadata.Builder ib = OFFactories.getFactory(fmb.getVersion()).instructions().buildWriteMetadata();

	// Process tokens (should be metadata or its mask)
	String[] keyValue = inst.split("/");	
	if (keyValue.length > 2) {
		throw new IllegalArgumentException("[Metadata, Mask] " + keyValue + " does not have form 'metadata/mask' or 'metadata' for parsing " + inst);
	} else if (keyValue.length == 1) {
		log.debug("No mask detected in OFInstructionWriteMetaData string.");
	} else if (keyValue.length == 2) {
		log.debug("Detected mask in OFInstructionWriteMetaData string.");
	}

	// Get the metadata
	if (keyValue[0].startsWith("0x")) {
		ib.setMetadata(U64.of(Long.valueOf(keyValue[0].replaceFirst("0x", ""), 16)));
	} else {
		ib.setMetadata(U64.of(Long.valueOf(keyValue[0])));
	}

	// Get the optional mask
	if (keyValue.length == 2) {
		if (keyValue[1].startsWith("0x")) {
			ib.setMetadataMask(U64.of(Long.valueOf(keyValue[1].replaceFirst("0x", ""), 16)));
		} else {
			ib.setMetadataMask(U64.of(Long.valueOf(keyValue[1])));
		}
	} else {
		ib.setMetadataMask(U64.NO_MASK);
	}

	log.debug("Appending WriteMetadata instruction: {}", ib.build());
	appendInstruction(fmb, ib.build());
	log.debug("All instructions after append: {}", fmb.getInstructions());
}
 
Example 17
Project: happylifeplat-transaction   File: LogUtil.java   View Source Code Vote up 4 votes
public static  void debug(Logger logger ,Supplier<Object> supplier){
    if(logger.isDebugEnabled()){
        logger.debug(Objects.toString(supplier.get()));
    }
}
 
Example 18
Project: soabase-stages   File: Slf4JTracing.java   View Source Code Vote up 4 votes
@Override
public void log(Logger logger, String str) {
    logger.debug(str);
}
 
Example 19
Project: openNaEF   File: NodeDetailPortFilter.java   View Source Code Vote up 4 votes
@Override
public boolean match(PortDto port) {
    Logger log = LoggerFactory.getLogger(PortsModel.class);
    if (port == null) {
        return false;
    } else if (port.getIfname() == null) {
            return false;
    } else if (port.isAlias()) {
        return true;
    }
    if (port instanceof EthPortDto) {
        if (port.getOwner() instanceof HardwareDto) {
            return true;
        } else if (port.getOwner() instanceof NodeDto) {
            return true;
        } else {
            return false;
        }
    } else if (port instanceof HardPortDto) {
        return true;
    } else if (port instanceof AtmApsIfDto) {
        return true;
    } else if (port instanceof PosApsIfDto) {
        return true;
    } else if (port instanceof EthLagIfDto) {
        return true;
    } else if (port instanceof TdmSerialIfDto) {
        return true;
    } else if (port instanceof IpIfDto) {
        IpIfDto ip = (IpIfDto) port;
        if (NodeUtil.isLoopback(ip)) {
            return true;
        } else if (DtoUtil.getStringOrNull(ip, ATTR.PORT_TYPE) != null) {
            return true;
        }
    } else if (port instanceof AtmPvcIfDto) {
        return true;
    } else if (port instanceof AtmPvpIfDto) {
        return !NodeUtil.isImplicit(port);
    } else if (port instanceof FrPvcIfDto) {
        return true;
    } else if (port instanceof VlanIfDto) {
        NodeElementDto owner = port.getOwner();
        if (owner != null && owner instanceof PortDto) {
            return true;
        }
        return DtoUtil.getBoolean(port, MPLSNMS_ATTR.SVI_ENABLED);
    }
    log.debug("filtered:(" + port.getClass().getSimpleName() + ")" + port.getAbsoluteName());
    return false;
}
 
Example 20
Project: QDrill   File: DefaultSqlHandler.java   View Source Code Vote up 4 votes
protected static void log(final String name, final RelNode node, final Logger logger) {
  if (logger.isDebugEnabled()) {
    logger.debug(name + " : \n" + RelOptUtil.toString(node, SqlExplainLevel.ALL_ATTRIBUTES));
  }
}