@Test public void defaultWriter() { TinylogLoggingConfiguration config = new TinylogLoggingConfiguration(); Collection<Writer>[][] writers = config.createWriters(emptyList(), Level.TRACE, false); assertThat(writers).hasSize(2).allSatisfy(element -> assertThat(element).hasSize(5).allSatisfy(collection -> assertThat(collection).hasSize(1).allSatisfy(writer -> assertThat(writer).isNotNull()) ) ); }
@SuppressWarnings("unchecked") public Collection<Writer>[][] createWriters(final List<String> tags, final Level minimumLevel, final boolean writingThread) { if (RuntimeProvider.getProcessId() == Long.MIN_VALUE) { java.util.ServiceLoader.load(Writer.class); } Collection<Writer>[][] matrix = new Collection[tags.size() + 2][Level.values().length - 1]; ServiceLoader<Writer> loader = new ServiceLoader<Writer>(Writer.class, Map.class); Map<String, String> writerProperties = Configuration.getSiblings("writer"); if (writerProperties.isEmpty()) { writerProperties = Collections.singletonMap("writer", RuntimeProvider.getDefaultWriter()); } for (Entry<String, String> entry : writerProperties.entrySet()) { Map<String, String> configuration = Configuration.getChildren(entry.getKey()); String tag = configuration.get("tag"); Level level = ConfigurationParser.parse(configuration.get("level"), minimumLevel); if (level.ordinal() < minimumLevel.ordinal()) { level = minimumLevel; } String exception = Configuration.get("exception"); if (exception != null && !configuration.containsKey("exception")) { configuration.put("exception", exception); } configuration.put("ID", entry.getKey()); configuration.put("writingthread", Boolean.toString(writingThread)); Writer writer = loader.create(entry.getValue(), configuration); if (writer != null) { if (tag == null || tag.isEmpty()) { for (int tagIndex = 0; tagIndex < matrix.length; ++tagIndex) { addWriter(writer, matrix, tagIndex, level); } } else if (tag.equals("-")) { addWriter(writer, matrix, 0, level); } else { String[] tagArray = tag.split(","); for (String tagArrayItem : tagArray) { tagArrayItem = tagArrayItem.trim(); String[] tagLevelItem = tagArrayItem.split("@", 2); Level currentLevel; String currentTag; if (tagLevelItem.length == 1) { currentTag = tagArrayItem; currentLevel = level; } else { currentTag = tagLevelItem[0].trim(); currentLevel = ConfigurationParser.parse(tagLevelItem[1].trim(), level); } if (!tagArrayItem.isEmpty()) { addWriter(writer, matrix, tags.indexOf(currentTag) + 1, currentLevel); } } } } } for (int tagIndex = 0; tagIndex < matrix.length; ++tagIndex) { for (int levelIndex = 0; levelIndex < matrix[tagIndex].length; ++levelIndex) { if (matrix[tagIndex][levelIndex] == null) { matrix[tagIndex][levelIndex] = Collections.emptyList(); } } } return matrix; }
TinylogLoggingConfiguration { @SuppressWarnings("unchecked") public Collection<Writer>[][] createWriters(final List<String> tags, final Level minimumLevel, final boolean writingThread) { if (RuntimeProvider.getProcessId() == Long.MIN_VALUE) { java.util.ServiceLoader.load(Writer.class); } Collection<Writer>[][] matrix = new Collection[tags.size() + 2][Level.values().length - 1]; ServiceLoader<Writer> loader = new ServiceLoader<Writer>(Writer.class, Map.class); Map<String, String> writerProperties = Configuration.getSiblings("writer"); if (writerProperties.isEmpty()) { writerProperties = Collections.singletonMap("writer", RuntimeProvider.getDefaultWriter()); } for (Entry<String, String> entry : writerProperties.entrySet()) { Map<String, String> configuration = Configuration.getChildren(entry.getKey()); String tag = configuration.get("tag"); Level level = ConfigurationParser.parse(configuration.get("level"), minimumLevel); if (level.ordinal() < minimumLevel.ordinal()) { level = minimumLevel; } String exception = Configuration.get("exception"); if (exception != null && !configuration.containsKey("exception")) { configuration.put("exception", exception); } configuration.put("ID", entry.getKey()); configuration.put("writingthread", Boolean.toString(writingThread)); Writer writer = loader.create(entry.getValue(), configuration); if (writer != null) { if (tag == null || tag.isEmpty()) { for (int tagIndex = 0; tagIndex < matrix.length; ++tagIndex) { addWriter(writer, matrix, tagIndex, level); } } else if (tag.equals("-")) { addWriter(writer, matrix, 0, level); } else { String[] tagArray = tag.split(","); for (String tagArrayItem : tagArray) { tagArrayItem = tagArrayItem.trim(); String[] tagLevelItem = tagArrayItem.split("@", 2); Level currentLevel; String currentTag; if (tagLevelItem.length == 1) { currentTag = tagArrayItem; currentLevel = level; } else { currentTag = tagLevelItem[0].trim(); currentLevel = ConfigurationParser.parse(tagLevelItem[1].trim(), level); } if (!tagArrayItem.isEmpty()) { addWriter(writer, matrix, tags.indexOf(currentTag) + 1, currentLevel); } } } } } for (int tagIndex = 0; tagIndex < matrix.length; ++tagIndex) { for (int levelIndex = 0; levelIndex < matrix[tagIndex].length; ++levelIndex) { if (matrix[tagIndex][levelIndex] == null) { matrix[tagIndex][levelIndex] = Collections.emptyList(); } } } return matrix; } }
TinylogLoggingConfiguration { @SuppressWarnings("unchecked") public Collection<Writer>[][] createWriters(final List<String> tags, final Level minimumLevel, final boolean writingThread) { if (RuntimeProvider.getProcessId() == Long.MIN_VALUE) { java.util.ServiceLoader.load(Writer.class); } Collection<Writer>[][] matrix = new Collection[tags.size() + 2][Level.values().length - 1]; ServiceLoader<Writer> loader = new ServiceLoader<Writer>(Writer.class, Map.class); Map<String, String> writerProperties = Configuration.getSiblings("writer"); if (writerProperties.isEmpty()) { writerProperties = Collections.singletonMap("writer", RuntimeProvider.getDefaultWriter()); } for (Entry<String, String> entry : writerProperties.entrySet()) { Map<String, String> configuration = Configuration.getChildren(entry.getKey()); String tag = configuration.get("tag"); Level level = ConfigurationParser.parse(configuration.get("level"), minimumLevel); if (level.ordinal() < minimumLevel.ordinal()) { level = minimumLevel; } String exception = Configuration.get("exception"); if (exception != null && !configuration.containsKey("exception")) { configuration.put("exception", exception); } configuration.put("ID", entry.getKey()); configuration.put("writingthread", Boolean.toString(writingThread)); Writer writer = loader.create(entry.getValue(), configuration); if (writer != null) { if (tag == null || tag.isEmpty()) { for (int tagIndex = 0; tagIndex < matrix.length; ++tagIndex) { addWriter(writer, matrix, tagIndex, level); } } else if (tag.equals("-")) { addWriter(writer, matrix, 0, level); } else { String[] tagArray = tag.split(","); for (String tagArrayItem : tagArray) { tagArrayItem = tagArrayItem.trim(); String[] tagLevelItem = tagArrayItem.split("@", 2); Level currentLevel; String currentTag; if (tagLevelItem.length == 1) { currentTag = tagArrayItem; currentLevel = level; } else { currentTag = tagLevelItem[0].trim(); currentLevel = ConfigurationParser.parse(tagLevelItem[1].trim(), level); } if (!tagArrayItem.isEmpty()) { addWriter(writer, matrix, tags.indexOf(currentTag) + 1, currentLevel); } } } } } for (int tagIndex = 0; tagIndex < matrix.length; ++tagIndex) { for (int levelIndex = 0; levelIndex < matrix[tagIndex].length; ++levelIndex) { if (matrix[tagIndex][levelIndex] == null) { matrix[tagIndex][levelIndex] = Collections.emptyList(); } } } return matrix; } TinylogLoggingConfiguration(); }
TinylogLoggingConfiguration { @SuppressWarnings("unchecked") public Collection<Writer>[][] createWriters(final List<String> tags, final Level minimumLevel, final boolean writingThread) { if (RuntimeProvider.getProcessId() == Long.MIN_VALUE) { java.util.ServiceLoader.load(Writer.class); } Collection<Writer>[][] matrix = new Collection[tags.size() + 2][Level.values().length - 1]; ServiceLoader<Writer> loader = new ServiceLoader<Writer>(Writer.class, Map.class); Map<String, String> writerProperties = Configuration.getSiblings("writer"); if (writerProperties.isEmpty()) { writerProperties = Collections.singletonMap("writer", RuntimeProvider.getDefaultWriter()); } for (Entry<String, String> entry : writerProperties.entrySet()) { Map<String, String> configuration = Configuration.getChildren(entry.getKey()); String tag = configuration.get("tag"); Level level = ConfigurationParser.parse(configuration.get("level"), minimumLevel); if (level.ordinal() < minimumLevel.ordinal()) { level = minimumLevel; } String exception = Configuration.get("exception"); if (exception != null && !configuration.containsKey("exception")) { configuration.put("exception", exception); } configuration.put("ID", entry.getKey()); configuration.put("writingthread", Boolean.toString(writingThread)); Writer writer = loader.create(entry.getValue(), configuration); if (writer != null) { if (tag == null || tag.isEmpty()) { for (int tagIndex = 0; tagIndex < matrix.length; ++tagIndex) { addWriter(writer, matrix, tagIndex, level); } } else if (tag.equals("-")) { addWriter(writer, matrix, 0, level); } else { String[] tagArray = tag.split(","); for (String tagArrayItem : tagArray) { tagArrayItem = tagArrayItem.trim(); String[] tagLevelItem = tagArrayItem.split("@", 2); Level currentLevel; String currentTag; if (tagLevelItem.length == 1) { currentTag = tagArrayItem; currentLevel = level; } else { currentTag = tagLevelItem[0].trim(); currentLevel = ConfigurationParser.parse(tagLevelItem[1].trim(), level); } if (!tagArrayItem.isEmpty()) { addWriter(writer, matrix, tags.indexOf(currentTag) + 1, currentLevel); } } } } } for (int tagIndex = 0; tagIndex < matrix.length; ++tagIndex) { for (int levelIndex = 0; levelIndex < matrix[tagIndex].length; ++levelIndex) { if (matrix[tagIndex][levelIndex] == null) { matrix[tagIndex][levelIndex] = Collections.emptyList(); } } } return matrix; } TinylogLoggingConfiguration(); @SuppressWarnings("unchecked") Collection<Writer>[][] createWriters(final List<String> tags, final Level minimumLevel, final boolean writingThread); Level calculateMinimumLevel(final Level globalLevel, final Map<String, Level> customLevels); @SuppressWarnings("unchecked") Collection<LogEntryValue>[][] calculateRequiredLogEntryValues(final Collection<Writer>[][] writers); BitSet calculateFullStackTraceRequirements(final Collection<LogEntryValue>[][] logEntryValues); WritingThread createWritingThread(final Collection<Writer>[][] matrix); static Collection<Writer> getAllWriters(final Collection<Writer>[][] matrix); static LogEntry createLogEntry(final StackTraceElement stackTraceElement, final String tag, 
		final Level level, final Throwable exception, final MessageFormatter formatter, final Object obj,
		final Object[] arguments, final Collection<LogEntryValue>[] requiredLogEntryValues, 
		final TinylogContextProvider contextProvider); }
TinylogLoggingConfiguration { @SuppressWarnings("unchecked") public Collection<Writer>[][] createWriters(final List<String> tags, final Level minimumLevel, final boolean writingThread) { if (RuntimeProvider.getProcessId() == Long.MIN_VALUE) { java.util.ServiceLoader.load(Writer.class); } Collection<Writer>[][] matrix = new Collection[tags.size() + 2][Level.values().length - 1]; ServiceLoader<Writer> loader = new ServiceLoader<Writer>(Writer.class, Map.class); Map<String, String> writerProperties = Configuration.getSiblings("writer"); if (writerProperties.isEmpty()) { writerProperties = Collections.singletonMap("writer", RuntimeProvider.getDefaultWriter()); } for (Entry<String, String> entry : writerProperties.entrySet()) { Map<String, String> configuration = Configuration.getChildren(entry.getKey()); String tag = configuration.get("tag"); Level level = ConfigurationParser.parse(configuration.get("level"), minimumLevel); if (level.ordinal() < minimumLevel.ordinal()) { level = minimumLevel; } String exception = Configuration.get("exception"); if (exception != null && !configuration.containsKey("exception")) { configuration.put("exception", exception); } configuration.put("ID", entry.getKey()); configuration.put("writingthread", Boolean.toString(writingThread)); Writer writer = loader.create(entry.getValue(), configuration); if (writer != null) { if (tag == null || tag.isEmpty()) { for (int tagIndex = 0; tagIndex < matrix.length; ++tagIndex) { addWriter(writer, matrix, tagIndex, level); } } else if (tag.equals("-")) { addWriter(writer, matrix, 0, level); } else { String[] tagArray = tag.split(","); for (String tagArrayItem : tagArray) { tagArrayItem = tagArrayItem.trim(); String[] tagLevelItem = tagArrayItem.split("@", 2); Level currentLevel; String currentTag; if (tagLevelItem.length == 1) { currentTag = tagArrayItem; currentLevel = level; } else { currentTag = tagLevelItem[0].trim(); currentLevel = ConfigurationParser.parse(tagLevelItem[1].trim(), level); } if (!tagArrayItem.isEmpty()) { addWriter(writer, matrix, tags.indexOf(currentTag) + 1, currentLevel); } } } } } for (int tagIndex = 0; tagIndex < matrix.length; ++tagIndex) { for (int levelIndex = 0; levelIndex < matrix[tagIndex].length; ++levelIndex) { if (matrix[tagIndex][levelIndex] == null) { matrix[tagIndex][levelIndex] = Collections.emptyList(); } } } return matrix; } TinylogLoggingConfiguration(); @SuppressWarnings("unchecked") Collection<Writer>[][] createWriters(final List<String> tags, final Level minimumLevel, final boolean writingThread); Level calculateMinimumLevel(final Level globalLevel, final Map<String, Level> customLevels); @SuppressWarnings("unchecked") Collection<LogEntryValue>[][] calculateRequiredLogEntryValues(final Collection<Writer>[][] writers); BitSet calculateFullStackTraceRequirements(final Collection<LogEntryValue>[][] logEntryValues); WritingThread createWritingThread(final Collection<Writer>[][] matrix); static Collection<Writer> getAllWriters(final Collection<Writer>[][] matrix); static LogEntry createLogEntry(final StackTraceElement stackTraceElement, final String tag, 
		final Level level, final Throwable exception, final MessageFormatter formatter, final Object obj,
		final Object[] arguments, final Collection<LogEntryValue>[] requiredLogEntryValues, 
		final TinylogContextProvider contextProvider);  }