/** * Get the current date formatted in this way * {@link TimeUtils#DATE_FORMATTER_TILL_MILLIS} * * @return */ public static String getFormattedDateTillMilliseconds() { return getFormattedDateTillMilliseconds(new Date()); }
private void handlePollError( long currentTimestamp, String monitorDescription, Throwable th ) { Integer monitorErrors = 0; if( pollErrors.containsKey( monitorDescription ) ) { monitorErrors = pollErrors.get( monitorDescription ); } monitorErrors++; pollErrors.put( monitorDescription, monitorErrors ); if( monitorErrors < MAX_NUMBER_LOGGED_ERRORS ) { log.error( "Error polling monitor '" + monitorDescription + "'. All polled values from all monitors will be skipped for " + TimeUtils.getFormattedDateTillMilliseconds( new Date( currentTimestamp ) ) + " timestamp", th ); } else if( monitorErrors == MAX_NUMBER_LOGGED_ERRORS ) { log.error( "This is the " + MAX_NUMBER_LOGGED_ERRORS + "th and last time we are logging polling error for monitor: " + monitorDescription, th ); } } }
private void log( String level, String message ) { sb.setLength(0); // clear the builder sb.append(ATS_CONSOLE_MESSAGE_PREFIX).append(" "); String now = TimeUtils.getFormattedDateTillMilliseconds(); if (!StringUtils.isNullOrEmpty(level)) { if (level.length() < 5) { // 5 is the max number of chars for level ID String (ERROR, TRACE, DEBUG) // in order to preserve some kind of padding, if the level ID String is shorter, add additional space char after it sb.append(level.toUpperCase()).append(" ").append(" "); } else { sb.append(level.toUpperCase()).append(" "); } } sb.append(now).append(" "); if (this.classNameTokens.length < 2) { sb.append(this.callingClass.getSimpleName()); } else { sb.append(this.classNameTokens[this.classNameTokens.length - 2]) .append(".") .append(this.classNameTokens[this.classNameTokens.length - 1]); } sb.append(": ").append(message); System.out.println(sb.toString()); }
throw new DbAppenederException(TimeUtils.getFormattedDateTillMilliseconds() + ": " + "Main thread interrupted while waiting for event "