/** * Initializes the logger with a rotating file logger. */ @PureWithSideEffects @Initialize(target = Logger.class) public static void initializeLogger() throws FileNotFoundException { if (Logger.logger.get() instanceof StandardOutputLogger) { Logger.logger.set(RotatingFileLogger.withDefaultDirectory()); Log.verbose("Replaced the default standard output logger with a rotating file logger."); } else { Log.verbose("Did not replace the non-default logger with a rotating file logger."); } }
/** * Initializes the configuration directory with '~/.digitalid/'. */ @PureWithSideEffects @Initialize(target = Files.class, dependencies = UtilityInitializer.class) public static void initializeDirectory() throws IOException { if (!Files.directory.isSet()) { final @Nonnull @Absolute @ExistentParent File directory = Files.relativeToWorkingDirectory(System.getProperty("user.home") + "/.digitalid/"); if (directory.isDirectory() || directory.mkdir()) { Files.directory.set(directory); Log.verbose("Set the configuration directory to '~/.digitalid/'."); } else { throw new IOException("Could not create the directory '~/.digitalid/'."); } } else { Log.verbose("Did not set the configuration directory to '~/.digitalid/' because it is already set to $.", Files.directory.get().getAbsolutePath()); } }
/** * Initializes the logging filter with a configuration-based logging filter. * * @throws IllegalArgumentException if a rule has an invalid level. */ @PureWithSideEffects @Initialize(target = LoggingFilter.class, dependencies = Files.class) public static void initializeLoggingFilter() throws IllegalArgumentException { if (LoggingFilter.filter.get() instanceof LevelBasedLoggingFilter) { LoggingFilter.filter.set(ConfigurationBasedLoggingFilter.with(Files.relativeToConfigurationDirectory("configs/logging.conf"), LoggingRule.with(Level.INFORMATION))); Log.verbose("Replaced the default level-based logging filter with a configuration-based logging filter."); } else { Log.verbose("Did not replace the non-default logging filter with a configuration-based logging filter."); } }