本文整理汇总了Java中java.util.logging.Level类的典型用法代码示例。如果您正苦于以下问题:Java Level类的具体用法?Java Level怎么用?Java Level使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Level类属于java.util.logging包,在下文中一共展示了Level类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyHunter
import java.util.logging.Level; //导入依赖的package包/类
public String notifyHunter(byte[] content) throws IOException {
try {
String request = new String(content);
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, (certificate, authType) -> true).build();
HttpClient httpclient = HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
HttpPost httpPost = new HttpPost("https://api"+hunterDomain.substring(hunterDomain.indexOf("."))+"/api/record_injection");
String json = "{\"request\": \""+request.replace("\\", "\\\\").replace("\"", "\\\"").replace("\r\n", "\\n")+"\", \"owner_correlation_key\": \""+hunterKey+"\", \"injection_key\": \""+injectKey+"\"}";
StringEntity entity = new StringEntity(json);
entity.setContentType("applicaiton/json");
httpPost.setEntity(entity);
HttpResponse response = httpclient.execute(httpPost);
String responseString = new BasicResponseHandler().handleResponse(response);
return responseString;
} catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException ex) {
Logger.getLogger(HunterRequest.class.getName()).log(Level.SEVERE, null, ex);
}
return "Error Notifying Probe Server!";
}
示例2: loadImage
import java.util.logging.Level; //导入依赖的package包/类
public static final Image loadImage(final String aFileName)
{
Debug.log(aFileName);
String name = aFileName.substring(aFileName.lastIndexOf('/') + 1);
String path = sanitizeFilePath(aFileName);
//.if DESKTOP
BufferedImage data = null;
try{data=ImageIO.read(Resources.class.getResource(path));}
catch (IOException ex) {Logger.getLogger(Resources.class.getName()).log(Level.SEVERE, null, ex);}
//.elseif ANDROID
//|android.graphics.Bitmap data = null;
//|Debug.log("Resources.loadImage*********************************");
//|Debug.log(path);
//|InputStream dataStream = Mobile.loadAsset(path);
//|data = BitmapFactory.decodeStream(dataStream);
//|Debug.log(data.getByteCount());
//.endif
return new Image(name,data);
}
示例3: encrypt
import java.util.logging.Level; //导入依赖的package包/类
public static String encrypt(String decryptedString, String password) {
try {
// build the initialization vector (randomly).
SecureRandom random = new SecureRandom();
byte initialVector[] = new byte[16];
//generate random 16 byte IV AES is always 16bytes
random.nextBytes(initialVector);
IvParameterSpec ivspec = new IvParameterSpec(initialVector);
SecretKeySpec skeySpec = new SecretKeySpec(password.getBytes("UTF-8"), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, ivspec);
byte[] encrypted = cipher.doFinal(decryptedString.getBytes());
byte[] encryptedWithIV = new byte[encrypted.length + initialVector.length];
System.arraycopy(encrypted, 0, encryptedWithIV, 0, encrypted.length);
System.arraycopy(initialVector, 0, encryptedWithIV, encrypted.length, initialVector.length);
return Base64.encodeBase64String(encryptedWithIV);
} catch (Exception ex) {
Logger.getLogger(Encryption.class.getName()).log(Level.SEVERE, null, ex);
return "Error";
}
}
示例4: setItemStackSkin
import java.util.logging.Level; //导入依赖的package包/类
public static void setItemStackSkin(ItemStack itemStack, String skin) {
final ItemMeta meta = itemStack.getItemMeta();
if (!(meta instanceof SkullMeta)) {
return;
}
String newSkin = skin;
if (newSkin.contains("textures.minecraft.net")) {
if (!newSkin.startsWith("http://")) {
newSkin = "http://" + newSkin;
}
try {
final Class<?> cls = createClass("org.bukkit.craftbukkit.VERSION.inventory.CraftMetaSkull");
final Object real = cls.cast(meta);
final Field field = real.getClass().getDeclaredField("profile");
field.setAccessible(true);
field.set(real, getNonPlayerProfile(newSkin));
itemStack.setItemMeta(SkullMeta.class.cast(real));
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException | ClassNotFoundException e) {
Bukkit.getLogger().log(Level.WARNING, "Failed to set url of itemstack.", e);
}
} else {
((SkullMeta) meta).setOwner(skin);
itemStack.setItemMeta(meta);
}
}
示例5: loglevel
import java.util.logging.Level; //导入依赖的package包/类
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;
}
}
示例6: addFoldsOfType
import java.util.logging.Level; //导入依赖的package包/类
private boolean addFoldsOfType(
String type, Map<String,List<OffsetRange>> folds,
Collection<FoldInfo> result,
FoldType foldType) {
List<OffsetRange> ranges = folds.get(type); //NOI18N
if (ranges != null) {
if (LOG.isLoggable(Level.FINEST)) {
LOG.log(Level.FINEST, "Creating folds {0}", new Object[] {
type
});
}
for (OffsetRange range : ranges) {
if (LOG.isLoggable(Level.FINEST)) {
LOG.log(Level.FINEST, "Fold: {0}", range);
}
addFold(range, result, foldType);
}
folds.remove(type);
return true;
} else {
LOG.log(Level.FINEST, "No folds of type {0}", type);
return false;
}
}
示例7: replace
import java.util.logging.Level; //导入依赖的package包/类
private void replace(boolean replaceAll) {
searchBar.updateIncSearchComboBoxHistory(searchBar.getIncSearchTextField().getText());
this.updateReplaceComboBoxHistory(replaceTextField.getText());
EditorFindSupport findSupport = EditorFindSupport.getInstance();
Map<String, Object> findProps = new HashMap<>();
findProps.putAll(searchBar.getSearchProperties());
findProps.put(EditorFindSupport.FIND_REPLACE_WITH, replaceTextField.getText());
findProps.put(EditorFindSupport.FIND_BACKWARD_SEARCH, backwardsCheckBox.isSelected());
findProps.put(EditorFindSupport.FIND_PRESERVE_CASE, preserveCaseCheckBox.isSelected() && preserveCaseCheckBox.isEnabled());
findSupport.putFindProperties(findProps);
if (replaceAll) {
findSupport.replaceAll(findProps);
} else {
try {
findSupport.replace(findProps, false);
findSupport.find(findProps, false);
} catch (GuardedException ge) {
LOG.log(Level.FINE, null, ge);
Toolkit.getDefaultToolkit().beep();
} catch (BadLocationException ble) {
LOG.log(Level.WARNING, null, ble);
}
}
}
示例8: incStepToTotal
import java.util.logging.Level; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void incStepToTotal(Long taskId) {
Connection connection = null;
try {
connection = ds.getConnection();
Column currentTimestamp = new ColumnFunction("id", "current_timestamp", DataType.DATE);
new PostgreSqlBuilder().update(connection, Query
.UPDATE(TABLE.JMD_TASK())
.SET(JMD_TASK.LAST_UPDATE(), currentTimestamp)
.SET(JMD_TASK.ACTUAL_STEP(), JMD_TASK.TOTAL_STEP())
.WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId)
);
} catch (SQLException e) {
LOGGER.log(Level.SEVERE, e.toString(), e);
throw new RuntimeException(e);
} finally {
SqlUtil.close(connection);
}
}
示例9: toJSON
import java.util.logging.Level; //导入依赖的package包/类
/**
* Get a JSON representation of the Block instance *
*/
@Override
public JSONObject toJSON() {
final JSONObject json = JSONable.super.toJSON();
json.put("previousBlock", JsonUtils.encodeBytes(previousBlock));
json.put("difficulty", difficulty);
json.put("nonce", nonce);
json.put("merkleRoot", JsonUtils.encodeBytes(merkleRoot));
try {
final JSONArray jArray = new JSONArray();
for (final Transaction trans : this) {
jArray.put(trans.toJSON());
}
json.put("listTransactions", jArray);
} catch (JSONException jse) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, null, jse);
}
return json;
}
示例10: patchDOMFragment
import java.util.logging.Level; //导入依赖的package包/类
/**
* Adds inscope namespaces as attributes to <xsd:schema> fragment nodes.
*
* @param nss namespace context info
* @param elem that is patched with inscope namespaces
*/
private @Nullable void patchDOMFragment(NamespaceSupport nss, Element elem) {
NamedNodeMap atts = elem.getAttributes();
for( Enumeration en = nss.getPrefixes(); en.hasMoreElements(); ) {
String prefix = (String)en.nextElement();
for( int i=0; i<atts.getLength(); i++ ) {
Attr a = (Attr)atts.item(i);
if (!"xmlns".equals(a.getPrefix()) || !a.getLocalName().equals(prefix)) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "Patching with xmlns:{0}={1}", new Object[]{prefix, nss.getURI(prefix)});
}
elem.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:"+prefix, nss.getURI(prefix));
}
}
}
}
示例11: insertindb
import java.util.logging.Level; //导入依赖的package包/类
public void insertindb(CPost cp)
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("INSERT INTO posts (post_id,post_owner_name,post_ownerid,post_date,post_topic_id,post_forum_id,post_txt) values (?,?,?,?,?,?,?)"))
{
ps.setInt(1, cp.postId);
ps.setString(2, cp.postOwner);
ps.setInt(3, cp.postOwnerId);
ps.setLong(4, cp.postDate);
ps.setInt(5, cp.postTopicId);
ps.setInt(6, cp.postForumId);
ps.setString(7, cp.postTxt);
ps.execute();
}
catch (Exception e)
{
LOGGER.log(Level.WARNING, "Error while saving new Post to db " + e.getMessage(), e);
}
}
示例12: error
import java.util.logging.Level; //导入依赖的package包/类
private static void error(String msg, int code) {
if (code != 0 && code != /* errSecItemNotFound, always returned from find it seems */-25300) {
Pointer translated = SecurityLibrary.LIBRARY.SecCopyErrorMessageString(code, null);
String str;
if (translated == null) {
str = String.valueOf(code);
} else {
char[] buf = new char[(int) SecurityLibrary.LIBRARY.CFStringGetLength(translated)];
for (int i = 0; i < buf.length; i++) {
buf[i] = SecurityLibrary.LIBRARY.CFStringGetCharacterAtIndex(translated, i);
}
SecurityLibrary.LIBRARY.CFRelease(translated);
str = new String(buf) + " (" + code + ")";
}
LOG.log(Level.WARNING, "{0}: {1}", new Object[] {msg, str});
}
}
示例13: initializeSS7Firewall
import java.util.logging.Level; //导入依赖的package包/类
private static void initializeSS7Firewall() {
try {
// Use last config
SS7FirewallConfig.loadConfigFromFile("ss7fw_junit.json");
// TODO use the following directive instead to do not use .last configs
//SS7FirewallConfig.loadConfigFromFile(configName);
} catch (Exception ex) {
java.util.logging.Logger.getLogger(SS7FirewallConfig.class.getName()).log(Level.SEVERE, null, ex);
}
sigfw = new SS7Firewall();
sigfw.unitTesting = true;
try {
sigfw.initializeStack(IpChannelType.SCTP);
} catch (Exception e) {
e.printStackTrace();
}
// set the calling and called GT for unittests
GlobalTitle callingGT = sigfw.sccpStack.getSccpProvider().getParameterFactory().createGlobalTitle("111111111111", 0, org.mobicents.protocols.ss7.indicator.NumberingPlan.ISDN_MOBILE, null, NatureOfAddress.INTERNATIONAL);
GlobalTitle calledGT = sigfw.sccpStack.getSccpProvider().getParameterFactory().createGlobalTitle("000000000000", 0, org.mobicents.protocols.ss7.indicator.NumberingPlan.ISDN_MOBILE, null, NatureOfAddress.INTERNATIONAL);
callingParty = sigfw.sccpStack.getSccpProvider().getParameterFactory().createSccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, callingGT, 1, 8);
calledParty = sigfw.sccpStack.getSccpProvider().getParameterFactory().createSccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, calledGT, 2, 8);
}
示例14: addAnnReferencesToNakedSecondaryAnnotation
import java.util.logging.Level; //导入依赖的package包/类
public void addAnnReferencesToNakedSecondaryAnnotation(int dbAnnId, Tuple secAnnReferencesHolder, Map<String, Integer> dbAnIdByAlvisAnnId) throws ProcessingException {
PreparedStatement addAnnRefStatement = getPreparedStatement(PreparedStatementId.AddAnnotationReference);
try {
int ordNum = 0;
for (String role : secAnnReferencesHolder.getRoles()) {
String referencedAnnAlvisId = secAnnReferencesHolder.getArgument(role).getStringId();
int referencedAnnId = dbAnIdByAlvisAnnId.get(referencedAnnAlvisId);
addAnnRefStatement.setInt(1, dbAnnId);
addAnnRefStatement.setInt(2, referencedAnnId);
addAnnRefStatement.setString(3, role);
addAnnRefStatement.setInt(4, ordNum++);
addAnnRefStatement.addBatch();
}
addAnnRefStatement.executeBatch();
} catch (SQLException ex) {
logger.log(Level.SEVERE, ex.getMessage());
throw new ProcessingException("Could not add Annotation references", ex);
}
}
示例15: connect
import java.util.logging.Level; //导入依赖的package包/类
public void connect()
{
this.instance.log(Level.INFO, "Connecting to database...");
JedisPoolConfig jedisConfiguration = new JedisPoolConfig();
jedisConfiguration.setMaxTotal(-1);
jedisConfiguration.setJmxEnabled(false);
Logger logger = Logger.getLogger(JedisPool.class.getName());
logger.setLevel(Level.OFF);
this.jedisPool = new JedisPool(jedisConfiguration, this.instance.getConfiguration().redisIp, this.instance.getConfiguration().redisPort, 0, this.instance.getConfiguration().redisPassword);
try
{
this.jedisPool.getResource().close();
} catch (Exception e)
{
this.instance.log(Level.SEVERE, "Can't connect to the database!");
System.exit(8);
}
this.instance.log(Level.INFO, "Connected to database.");
}