
net.vectorpublish.desktop.vp.log.Log Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2016, Peter Rader. All rights reserved.
* ___ ___ __ ______ __ __ __ __
* | | |.-----..----.| |_ .-----..----.| __ \.--.--.| |--.| ||__|.-----.| |--.
* | | || -__|| __|| _|| _ || _|| __/| | || _ || || ||__ --|| |
* \_____/ |_____||____||____||_____||__| |___| |_____||_____||__||__||_____||__|__|
*
* http://www.gnu.org/licenses/gpl-3.0.html
*/
package net.vectorpublish.desktop.vp.log;
import java.net.URL;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* A logger abstraction.
*/
public interface Log {
public class Performance {
private static final String SEPARATOR = ", ";
private static final int THREASHOLD = 3000;
private final long start = System.currentTimeMillis();
private final Map milestones = new LinkedHashMap<>();
private final String name;
public Performance(String name) {
this.name = name;
}
public void addMilestone(String name) {
milestones.put(System.currentTimeMillis(), name);
}
@Override
public String toString() {
long now = System.currentTimeMillis();
String text = name + ": ";
text += toHumanReadable(now - start);
long last = start;
for (Long out : milestones.keySet()) {
if (last == start) {
text += ": ";
} else {
text += SEPARATOR;
}
text += milestones.get(out) + " after ";
text += toHumanReadable(out - last);
last = out;
}
return text;
}
private static String toHumanReadable(long complete) {
if (complete > THREASHOLD) {
return Math.round(complete / 3000) + " seconds";
} else {
return complete + " miliseconds";
}
}
}
void cache(String what);;
void calculated(String what, Object result);
void checkThat(Object ob, String message);
void found(Object ob);
void log(Object ob);
void methodIn(String string);
void missing(Object ob, String sentence);
void notify(Object ob);
void override(String what, Object newValue, Object oldValue);
void searching(Object ob);
void show(Object obj);
void system(Object ob);
void user(Object ob);
void voteEnlargeLogging();
void voteShortenLogging();
Performance turing(String name);
void timeout(URL url, String string);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy