List of usage examples for java.util.logging Logger getGlobal
public static final Logger getGlobal()
From source file:io.sqp.client.impl.SqpConnectionImpl.java
public SqpConnectionImpl(ClientConfig config) { _logger = Logger.getGlobal(); _messageEncoder = new JacksonMessageEncoder(); _state = ConnectionState.Uninitialized; _config = config;/*from w w w .j a v a 2 s . c om*/ _cursorId = 0; _statementId = 0; _openServerResources = new HashMap<>(); _autocommit = true; _lobManager = new LobManager(this); _sendingService = Executors.newSingleThreadExecutor(); // important that this only one thread to assure correct order }
From source file:com.relicum.ipsum.io.PropertyIO.java
/** * Return a {@link java.util.Properties} read from the specified string file path. * * @param file the {@link java.nio.file.Path } name of the file to read the properties from. * @return the {@link java.util.Properties} instance. * @throws IOException the {@link java.io.IOException} if the file was not found or there were problems reading from it. *//* w ww. ja v a 2s .c om*/ default Properties readFromFile(File file) throws IOException { Validate.notNull(file); if (Files.exists(file.toPath())) throw new FileNotFoundException("File at " + file.getPath() + " was not found"); Properties properties = new Properties(); try { properties.load(Files.newBufferedReader(file.toPath(), Charset.defaultCharset())); } catch (IOException e) { Logger.getGlobal().log(Level.SEVERE, e.getMessage(), e.getCause()); throw e; } return properties; }
From source file:com.relicum.ipsum.io.PropertyIO.java
/** * Write the properties object to the specified string file path. * * @param properties an instance of a {@link java.util.Properties} object. * @param path the {@link java.nio.file.Path} that the properties will be written to. * @param message the message that is included in the header of properties files. * @throws IOException an {@link java.io.IOException} if their was a problem writing to the file. *///from w w w . j a va 2 s .c o m default void writeToFile(Properties properties, Path path, String message) throws IOException { Validate.notNull(properties); Validate.notNull(path); Validate.notNull(message); System.out.println(path); Files.deleteIfExists(path); try { properties.store(Files.newBufferedWriter(path, Charset.defaultCharset()), message); } catch (IOException e) { Logger.getGlobal().log(Level.SEVERE, e.getMessage(), e.getCause()); throw e; } }
From source file:dlauncher.authorization.DefaultCredentialsManager.java
@Override public void validateAndRefreshTokens() { Set<AuthorizationInfoImpl> toAdd = new HashSet<>(); Iterator<AuthorizationInfoImpl> loop = this.authDatabase.iterator(); while (loop.hasNext()) { AuthorizationInfoImpl v = loop.next(); if (!v.valid) { try { v.validate();/*from w w w. ja va2s . c o m*/ if (!v.isValidated()) { toAdd.add(v.refresh()); loop.remove(); } } catch (IOException | AuthorizationException ex) { Logger.getGlobal().log(Level.SEVERE, null, ex); v.setValid(false); } } } authDatabase.addAll(toAdd); }
From source file:at.tuwien.mnsa.smssender.SMSPDUConverter.java
/** * Get the PDU encoding for the given message * @param message/*from w w w . j av a 2 s . c o m*/ * @param rightshift of the content for concatination * @return */ public SMSPDUConversionResult getContent(String message, int rightshift) { List<Byte> finalized = new LinkedList<>(); BitSet currentWorkingBS = new BitSet(16); int currentShiftpos = 0; boolean currentlyExtended = false; int len = 0; //repeat while there are characters left while (message.length() > 0) { String c = message.substring(0, 1); message = message.substring(1); byte value; //loook up current character if (this.GSM_3GPP_TS_23_038.containsKey(c)) { value = this.GSM_3GPP_TS_23_038.get(c); } else { if (this.GSM_3GPP_TS_23_038_EXTENSION.containsKey(c)) { if (!currentlyExtended) { //extension -> now do the escape character! //do the "new" character the other round message = c + message; currentlyExtended = true; value = this.GSM_3GPP_TS_23_038.get("\u001B"); } else { //we just did the ecsape character, now do the char from //the extended alphabet value = this.GSM_3GPP_TS_23_038_EXTENSION.get(c); currentlyExtended = false; } } else { throw new RuntimeException("Not found: " + c); } } //start at 0x0 if (currentShiftpos == 0) { //add current char beginning at pos 0 addByteToBitset(value, currentWorkingBS, 0, 1, 7); } else { //else start at second byte and do flipping //make place for the right bits of the current char in the front currentWorkingBS = rightShiftBitset(currentWorkingBS, currentShiftpos); //add last X bits in front of the bitset addByteToBitset(value, currentWorkingBS, 0, 8 - currentShiftpos, currentShiftpos); //add the first X bits at the end of the bitset if any if (currentShiftpos < 7) { addByteToBitset(value, currentWorkingBS, 8, 1, 7 - currentShiftpos); } //the first byte of the bitset is now complete! :) byte finalByte = currentWorkingBS.toByteArray()[0]; finalByte = swapEndianFormat(finalByte); finalized.add(finalByte); //shift bitset left by 8 bits since we just finished and exported a byte currentWorkingBS = leftShiftBitset(currentWorkingBS, 8); } currentShiftpos = (currentShiftpos + 1) % 8; len++; //for first character -> just add to the bitset //addByteToBitset(value, bitset, i*7); /*//exchange characters for (int j=0;j<((i%8)*8-(i%8)*7);j++) { boolean cBit = content.get() }*/ } //add last byte (swap back our eagerly shifted byte) if (currentShiftpos == 7) { byte finalByte = 0x00; finalized.add(finalByte); } else if (currentShiftpos != 0) { byte finalByte = (currentWorkingBS.isEmpty()) ? 0x0 : currentWorkingBS.toByteArray()[0]; finalByte = swapEndianFormat(finalByte); //I don't really know why, //but java fills right shifts with 1s //so we have to manually set all new (left) bits to zero for (int i = 0; i < currentShiftpos; i++) { finalByte = (byte) (finalByte >> 1); finalByte = (byte) (finalByte & 0x7F); //unset first bit } //finalByte = (byte) (finalByte & 0x3F); finalized.add(finalByte); } byte[] finalM = ArrayUtils.toPrimitive(finalized.toArray(new Byte[finalized.size()])); Logger.getGlobal().info("1: " + DatatypeConverter.printHexBinary(finalM)); //in case of rightshift for concatenation -> right shift the whole array if (rightshift > 0) { BitSet bs = BitSet.valueOf(finalM); bs = rightShiftBitset(bs, rightshift); finalM = bs.toByteArray(); Logger.getGlobal().info("2: " + DatatypeConverter.printHexBinary(finalM)); } SMSPDUConversionResult res = new SMSPDUConversionResult(finalM, len); return res; }
From source file:dlauncher.dialogs.Login.java
private void login_write(String UserName, String Password) { Logger.getGlobal().info("Started login process"); Logger.getGlobal().info("Writing login data.."); try {/*from w w w . j a v a 2 s . c om*/ url = new URL("http://authserver.mojang.com/authenticate"); final URLConnection con = url.openConnection(); con.setConnectTimeout(5000); con.setReadTimeout(5000); con.setDoOutput(true); con.setDoInput(true); con.setRequestProperty("Content-Type", "application/json"); try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(con.getOutputStream()))) { writer.write("{\n" + " \"agent\": {" + " \"name\": \"Minecraft\"," + " \"version\": 1" + "\n" + " },\n" + " \"username\": \"" + UserName + "\",\n" + "\n" + " \"password\": \"" + Password + "\",\n" + "}"); writer.close(); } Logger.getGlobal().info("Succesful written login data"); } catch (MalformedURLException ex) { Logger.getGlobal().warning("Failed Writing login data,"); Logger.getLogger(Login.class.getName()).log(Level.SEVERE, "", ex); } catch (IOException ex) { Logger.getGlobal().warning("Failed Writing login data,"); Logger.getLogger(Login.class.getName()).log(Level.SEVERE, "", ex); } }
From source file:com.relicum.ipsum.io.PropertyIO.java
/** * Check if file exists at the give string path, if it does not, creates a new file and returns that. * * @param file the file/*from ww w .j a v a2s . c o m*/ * @return the file * @throws java.io.IOException the iO exception */ @SuppressWarnings("ResultOfMethodCallIgnored") default File checkFile(String file) throws IOException { Logger.getLogger("minecraft").info("The path tried is " + file); File tmp = new File(file); try { tmp.createNewFile(); } catch (IOException e) { Logger.getGlobal().log(Level.SEVERE, e.getMessage(), e.getCause()); throw e; } return tmp; }
From source file:org.jitsi.meet.test.base.FailureListener.java
/** * Saves the log from meet. Normally when clicked it is saved in Downloads * if we do not find it we skip it./*from ww w . j av a 2 s .c om*/ */ private void saveMeetDebugLog(Participant participant, String fileName) { try { String log = participant.getMeetDebugLog(); if (log != null) { FileUtils.write(new File(outputLogsParentFolder, fileName), log); } } catch (Exception e) { Logger.getGlobal().log(Level.SEVERE, "Failed to write meet logs for " + participant.getName(), e); } }
From source file:org.jitsi.meet.test.base.FailureListener.java
/** * Saves the rtp stats from meet./*from w ww . jav a 2s . c om*/ */ private void saveMeetRTPStats(Participant participant, String fileName) { try { String log = participant.getRTPStats(); if (log != null) { FileUtils.write(new File(outputLogsParentFolder, fileName), log); } } catch (Exception e) { Logger.getGlobal().log(Level.SEVERE, "Failed to write rtp stats for " + participant.getName(), e); } }
From source file:org.daxplore.producer.daxplorelib.raw.RawMeta.java
public List<RawMetaQuestion> getQuestions() throws SQLException { List<RawMetaQuestion> rawQuestionList = new LinkedList<>(); try (PreparedStatement stmt = connection.prepareStatement("SELECT * FROM rawmeta ORDER BY column ASC"); ResultSet rs = stmt.executeQuery()) { while (rs.next()) { RawMetaQuestion rmq = new RawMetaQuestion(); rmq.column = rs.getString("column"); rmq.longname = rs.getString("longname"); rmq.measure = rs.getString("measure"); rmq.qtext = rs.getString("qtext"); String qtype = rs.getString("qtype"); rmq.qtype = VariableType.valueOf(qtype); rmq.spsstype = rs.getString("spsstype"); String cats = rs.getString("valuelabels"); if (cats != null && !cats.isEmpty()) { try { rmq.valuelables = JSONtoCategories(rs.getString("valuelabels")); } catch (NumberFormatException e) { //TODO: send message to client Logger.getGlobal().log(Level.SEVERE, "Variable \"" + rmq.column + "\" was ignored"); continue; }//w ww. j a va 2s . co m } else { rmq.valuelables = new LinkedList<>(); } rawQuestionList.add(rmq); } } return rawQuestionList; }