@@ -53,12 +53,6 @@ public static Priority getByKey(String key) {
5353 private static String currentProfileKey ;
5454 private static ClogProfile currentProfile ;
5555
56- static {
57- profileSuppliers = new HashMap <>();
58- profiles = new HashMap <>();
59- profiles .put (null , new ClogProfile ());
60- }
61-
6256 /**
6357 * Get the instance of Clog to log to. If the instance is defined, use that profile, otherwise
6458 * create a new default profile.
@@ -437,6 +431,7 @@ public static int wtf(String message, Throwable throwable, Object... args) {
437431 * @param clog the profile
438432 */
439433 public static void addProfile (String key , ProfileSupplier clog ) {
434+ if (profileSuppliers == null ) profileSuppliers = new HashMap <>();
440435 profileSuppliers .put (key , clog );
441436 }
442437
@@ -446,6 +441,7 @@ public static void addProfile(String key, ProfileSupplier clog) {
446441 * @param key the key of the profile to remove
447442 */
448443 public static void removeProfile (String key ) {
444+ if (profiles == null ) profiles = new HashMap <>();
449445 profiles .remove (key );
450446 }
451447
@@ -455,6 +451,7 @@ public static void removeProfile(String key) {
455451 * @param key the key of the profile to use
456452 */
457453 public static ClogProfile setCurrentProfile (String key ) {
454+ if (profiles == null ) profiles = new HashMap <>();
458455 Clog .currentProfileKey = key ;
459456 Clog .currentProfile = profiles .get (key );
460457 return getInstance ();
@@ -477,6 +474,7 @@ public static ClogProfile setCurrentProfile(String key, ProfileSupplier clog) {
477474 * @return the map of profiles
478475 */
479476 public static Map <String , ClogProfile > getProfiles () {
477+ if (profiles == null ) profiles = new HashMap <>();
480478 return profiles ;
481479 }
482480
@@ -486,6 +484,7 @@ public static Map<String, ClogProfile> getProfiles() {
486484 * @param profiles the profile set to use
487485 */
488486 public static void setAllProfiles (Map <String , ClogProfile > profiles ) {
487+ if (profiles == null ) throw new NullPointerException ("profiles cannot be null" );
489488 Clog .profiles = profiles ;
490489 }
491490}
0 commit comments