/src/net/intensicode/idea/util/LoggerFactory.java

https://github.com/DanielLukic/idea-simple-syntax · Java · 36 lines · 26 code · 7 blank · 3 comment · 4 complexity · f9446a4e6539aa0690b55ebddda96402 MD5 · raw file

  1. package net.intensicode.idea.util;
  2. import com.intellij.openapi.diagnostic.Logger;
  3. import sun.reflect.Reflection;
  4. import java.util.HashMap;
  5. /**
  6. * TODO: Describe this!
  7. */
  8. public final class LoggerFactory
  9. {
  10. public static final Logger getLogger()
  11. {
  12. final Class callerClass = Reflection.getCallerClass( 2 );
  13. if ( theKnownLoggers.containsKey( callerClass ) == false )
  14. {
  15. final String category = callerClass.getSimpleName();
  16. theKnownLoggers.put( callerClass, new PluginLogger( category ) );
  17. }
  18. return theKnownLoggers.get( callerClass );
  19. }
  20. public static final Logger getLogger( final String aCategory )
  21. {
  22. if ( theKnownLoggers.containsKey( aCategory ) == false )
  23. {
  24. theKnownLoggers.put( aCategory, new PluginLogger( aCategory ) );
  25. }
  26. return theKnownLoggers.get( aCategory );
  27. }
  28. private static final HashMap<Object, Logger> theKnownLoggers = new HashMap<Object, Logger>();
  29. }