Removed clutter from log

v5stable
Ondřej Hruška 11 years ago
parent 99bb04ae43
commit ae785dc440
  1. 16
      src/mightypork/rogue/App.java
  2. 2
      src/mightypork/rogue/bus/events/MouseMotionEvent.java
  3. 2
      src/mightypork/rogue/bus/events/UpdateEvent.java
  4. 1
      src/mightypork/rogue/loading/AsyncResourceLoader.java
  5. 14
      src/mightypork/utils/control/bus/EventBus.java
  6. 17
      src/mightypork/utils/control/bus/events/types/UnloggedEvent.java
  7. 8
      src/mightypork/utils/logging/LogInstance.java

@ -167,6 +167,13 @@ public class App implements AppAccess {
inputSystem = new InputSystem(this); inputSystem = new InputSystem(this);
setupGlobalKeystrokes(); setupGlobalKeystrokes();
/*
* Prepare main loop
*/
Log.f1("Preparing game systems...");
screens = new ScreenRegistry(this);
mainLoop = new MainLoop(this, screens);
/* /*
* Load resources * Load resources
*/ */
@ -177,15 +184,8 @@ public class App implements AppAccess {
/* /*
* Screen registry * Screen registry
*/ */
Log.f2("Initializing screen registry..."); Log.f2("Initializing screens...");
screens = new ScreenRegistry(this);
initScreens(); initScreens();
/*
* Prepare main loop
*/
Log.f1("Preparing main loop...");
mainLoop = new MainLoop(this, screens);
} }

@ -2,6 +2,7 @@ package mightypork.rogue.bus.events;
import mightypork.utils.control.bus.events.Event; import mightypork.utils.control.bus.events.Event;
import mightypork.utils.control.bus.events.types.UnloggedEvent;
import mightypork.utils.math.coord.Coord; import mightypork.utils.math.coord.Coord;
@ -10,6 +11,7 @@ import mightypork.utils.math.coord.Coord;
* *
* @author MightyPork * @author MightyPork
*/ */
@UnloggedEvent
public class MouseMotionEvent implements Event<MouseMotionEvent.Listener> { public class MouseMotionEvent implements Event<MouseMotionEvent.Listener> {
private final Coord move; private final Coord move;

@ -3,6 +3,7 @@ package mightypork.rogue.bus.events;
import mightypork.utils.control.bus.events.Event; import mightypork.utils.control.bus.events.Event;
import mightypork.utils.control.bus.events.types.ImmediateEvent; import mightypork.utils.control.bus.events.types.ImmediateEvent;
import mightypork.utils.control.bus.events.types.UnloggedEvent;
import mightypork.utils.control.interf.Updateable; import mightypork.utils.control.interf.Updateable;
@ -13,6 +14,7 @@ import mightypork.utils.control.interf.Updateable;
*/ */
// sending via queue would hog the bus // sending via queue would hog the bus
@ImmediateEvent @ImmediateEvent
@UnloggedEvent
public class UpdateEvent implements Event<Updateable> { public class UpdateEvent implements Event<Updateable> {
private final double deltaTime; private final double deltaTime;

@ -71,7 +71,6 @@ public class AsyncResourceLoader extends Thread implements ResourceLoadRequest.L
@Override @Override
public void run() public void run()
{ {
System.out.println("~~");
def.load(); def.load();
} }
})); }));

@ -9,6 +9,7 @@ import mightypork.utils.control.bus.events.Event;
import mightypork.utils.control.bus.events.types.DelayedEvent; import mightypork.utils.control.bus.events.types.DelayedEvent;
import mightypork.utils.control.bus.events.types.ImmediateEvent; import mightypork.utils.control.bus.events.types.ImmediateEvent;
import mightypork.utils.control.bus.events.types.SingleReceiverEvent; import mightypork.utils.control.bus.events.types.SingleReceiverEvent;
import mightypork.utils.control.bus.events.types.UnloggedEvent;
import mightypork.utils.control.interf.Destroyable; import mightypork.utils.control.interf.Destroyable;
import mightypork.utils.logging.Log; import mightypork.utils.logging.Log;
@ -46,6 +47,13 @@ final public class EventBus implements Destroyable {
busThread.start(); busThread.start();
} }
private boolean shallLog(Event<?> event) {
if(!logSending) return false;
if(event.getClass().isAnnotationPresent(UnloggedEvent.class)) return false;
return true;
}
/** /**
* Add a {@link EventChannel} to this bus.<br> * Add a {@link EventChannel} to this bus.<br>
@ -150,7 +158,7 @@ final public class EventBus implements Destroyable {
final DelayQueueEntry dm = new DelayQueueEntry(delay, event); final DelayQueueEntry dm = new DelayQueueEntry(delay, event);
if (logSending) Log.f3("<bus> Q " + Log.str(event) + ", t = +" + delay + "s"); if (shallLog(event)) Log.f3("<bus> Q " + Log.str(event) + ", t = +" + delay + "s");
sendQueue.add(dm); sendQueue.add(dm);
} }
@ -167,7 +175,7 @@ final public class EventBus implements Destroyable {
{ {
assertLive(); assertLive();
if (logSending) Log.f3("<bus> D " + Log.str(event)); if (shallLog(event)) Log.f3("<bus> D " + Log.str(event));
dispatch(event); dispatch(event);
} }
@ -203,7 +211,7 @@ final public class EventBus implements Destroyable {
} }
if (!accepted) Log.e("<bus> Not accepted by any channel: " + Log.str(event)); if (!accepted) Log.e("<bus> Not accepted by any channel: " + Log.str(event));
if (logSending && !sent) Log.w("<bus> Not delivered: " + Log.str(event)); if (!sent && shallLog(event)) Log.w("<bus> Not delivered: " + Log.str(event));
channels.setBuffering(false); channels.setBuffering(false);
clients.setBuffering(false); clients.setBuffering(false);

@ -0,0 +1,17 @@
package mightypork.utils.control.bus.events.types;
import java.lang.annotation.*;
/**
* Event that's not worth logging, unless there was an error with it.<br>
* Useful for common events that would otherwise clutter the log.
*
* @author MightyPork
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
@Documented
public @interface UnloggedEvent {}

@ -103,8 +103,8 @@ public class LogInstance {
logger.setUseParentHandlers(false); logger.setUseParentHandlers(false);
logger.setLevel(Level.ALL); logger.setLevel(Level.ALL);
logger.info("Logger \""+name+"\" initialized."); String stamp = (new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).format(new Date());
logger.info((new SimpleDateFormat("yyyy/MM/dd HH:mm:ss")).format(new Date())); i("= Logger \""+name+"\" initialized =\n"+stamp);
} }
@ -240,7 +240,7 @@ public class LogInstance {
if (enabled) { if (enabled) {
logger.log(level, msg, t); logger.log(level, msg, t);
String fmt = formatMessage(level, msg, null); String fmt = formatMessage(level, msg, t);
for (final LogMonitor mon : monitors.values()) { for (final LogMonitor mon : monitors.values()) {
mon.onMessageLogged(level, fmt); mon.onMessageLogged(level, fmt);
@ -323,7 +323,7 @@ public class LogInstance {
*/ */
public void e(String msg, Throwable thrown) public void e(String msg, Throwable thrown)
{ {
log(Level.SEVERE, msg); log(Level.SEVERE, msg, thrown);
} }

Loading…
Cancel
Save