repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/ConfigurationParser.java
ConfigurationParser.getLocale
public static Locale getLocale() { String tag = Configuration.get("locale"); if (tag == null) { return Locale.ROOT; } else { String[] splittedTag = tag.split("_", MAX_LOCALE_ARGUMENTS); if (splittedTag.length == 1) { return new Locale(splittedTag[0]); } else if (splittedTag.length == 2) { retu...
java
public static Locale getLocale() { String tag = Configuration.get("locale"); if (tag == null) { return Locale.ROOT; } else { String[] splittedTag = tag.split("_", MAX_LOCALE_ARGUMENTS); if (splittedTag.length == 1) { return new Locale(splittedTag[0]); } else if (splittedTag.length == 2) { retu...
[ "public", "static", "Locale", "getLocale", "(", ")", "{", "String", "tag", "=", "Configuration", ".", "get", "(", "\"locale\"", ")", ";", "if", "(", "tag", "==", "null", ")", "{", "return", "Locale", ".", "ROOT", ";", "}", "else", "{", "String", "[",...
Loads the locale from configuration. @return Locale from configuration or {@link Locale#ROOT} if no locale is configured
[ "Loads", "the", "locale", "from", "configuration", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/ConfigurationParser.java#L50-L64
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/ConfigurationParser.java
ConfigurationParser.getCustomLevels
public static Map<String, Level> getCustomLevels() { Map<String, Level> levels = new HashMap<String, Level>(); for (Entry<String, String> entry : Configuration.getSiblings("level@").entrySet()) { String packageOrClass = entry.getKey().substring("level@".length()); Level level = parse(entry.getValue(), null); ...
java
public static Map<String, Level> getCustomLevels() { Map<String, Level> levels = new HashMap<String, Level>(); for (Entry<String, String> entry : Configuration.getSiblings("level@").entrySet()) { String packageOrClass = entry.getKey().substring("level@".length()); Level level = parse(entry.getValue(), null); ...
[ "public", "static", "Map", "<", "String", ",", "Level", ">", "getCustomLevels", "(", ")", "{", "Map", "<", "String", ",", "Level", ">", "levels", "=", "new", "HashMap", "<", "String", ",", "Level", ">", "(", ")", ";", "for", "(", "Entry", "<", "Str...
Loads custom severity levels for packages or classes from configuration. @return All found custom severity levels
[ "Loads", "custom", "severity", "levels", "for", "packages", "or", "classes", "from", "configuration", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/ConfigurationParser.java#L80-L90
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/ConfigurationParser.java
ConfigurationParser.getTags
public static List<String> getTags() { List<String> tags = new ArrayList<String>(); for (String writerProperty : Configuration.getSiblings("writer").keySet()) { String tag = Configuration.get(writerProperty + ".tag"); if (tag != null && !tag.isEmpty() && !tag.equals("-") && !tags.contains(tag)) { tags.add...
java
public static List<String> getTags() { List<String> tags = new ArrayList<String>(); for (String writerProperty : Configuration.getSiblings("writer").keySet()) { String tag = Configuration.get(writerProperty + ".tag"); if (tag != null && !tag.isEmpty() && !tag.equals("-") && !tags.contains(tag)) { tags.add...
[ "public", "static", "List", "<", "String", ">", "getTags", "(", ")", "{", "List", "<", "String", ">", "tags", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "writerProperty", ":", "Configuration", ".", "getSiblings", ...
Loads all tags from writers in configuration. @return Found tags
[ "Loads", "all", "tags", "from", "writers", "in", "configuration", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/ConfigurationParser.java#L97-L106
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/ConfigurationParser.java
ConfigurationParser.addWriter
private static void addWriter(final Writer writer, final Collection<Writer>[][] matrix, final int tagIndex, final Level level) { for (int levelIndex = level.ordinal(); levelIndex < Level.OFF.ordinal(); ++levelIndex) { Collection<Writer> collection = matrix[tagIndex][levelIndex]; if (collection == null) { co...
java
private static void addWriter(final Writer writer, final Collection<Writer>[][] matrix, final int tagIndex, final Level level) { for (int levelIndex = level.ordinal(); levelIndex < Level.OFF.ordinal(); ++levelIndex) { Collection<Writer> collection = matrix[tagIndex][levelIndex]; if (collection == null) { co...
[ "private", "static", "void", "addWriter", "(", "final", "Writer", "writer", ",", "final", "Collection", "<", "Writer", ">", "[", "]", "[", "]", "matrix", ",", "final", "int", "tagIndex", ",", "final", "Level", "level", ")", "{", "for", "(", "int", "lev...
Adds a writer to a well-defined matrix. The given writer will be added only at the given tag index for severity levels equal or above the given severity level. @param writer Writer to add @param matrix Well-defined two-dimensional matrix @param tagIndex Represents the tag (first dimension of matrix) @param level Repre...
[ "Adds", "a", "writer", "to", "a", "well", "-", "defined", "matrix", ".", "The", "given", "writer", "will", "be", "added", "only", "at", "the", "given", "tag", "index", "for", "severity", "levels", "equal", "or", "above", "the", "given", "severity", "leve...
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/ConfigurationParser.java#L203-L212
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/ConfigurationParser.java
ConfigurationParser.parse
private static Level parse(final String property, final Level defaultValue) { if (property == null) { return defaultValue; } else { try { return Level.valueOf(property.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException ex) { InternalLogger.log(Level.ERROR, "Illegal severity level: " + pro...
java
private static Level parse(final String property, final Level defaultValue) { if (property == null) { return defaultValue; } else { try { return Level.valueOf(property.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException ex) { InternalLogger.log(Level.ERROR, "Illegal severity level: " + pro...
[ "private", "static", "Level", "parse", "(", "final", "String", "property", ",", "final", "Level", "defaultValue", ")", "{", "if", "(", "property", "==", "null", ")", "{", "return", "defaultValue", ";", "}", "else", "{", "try", "{", "return", "Level", "."...
Reads a severity level from configuration. @param property Key of property @param defaultValue Default value, if property doesn't exist or is invalid @return Severity level
[ "Reads", "a", "severity", "level", "from", "configuration", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/ConfigurationParser.java#L223-L234
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java
TinylogLoggingProvider.calculateMinimumLevel
private static Level calculateMinimumLevel(final Level globalLevel, final Map<String, Level> customLevels) { Level minimumLevel = globalLevel; for (Level level : customLevels.values()) { if (level.ordinal() < minimumLevel.ordinal()) { minimumLevel = level; } } return minimumLevel; }
java
private static Level calculateMinimumLevel(final Level globalLevel, final Map<String, Level> customLevels) { Level minimumLevel = globalLevel; for (Level level : customLevels.values()) { if (level.ordinal() < minimumLevel.ordinal()) { minimumLevel = level; } } return minimumLevel; }
[ "private", "static", "Level", "calculateMinimumLevel", "(", "final", "Level", "globalLevel", ",", "final", "Map", "<", "String", ",", "Level", ">", "customLevels", ")", "{", "Level", "minimumLevel", "=", "globalLevel", ";", "for", "(", "Level", "level", ":", ...
Calculates the minimum severity level that can output any log entries. @param globalLevel Global severity level @param customLevels Custom severity levels for packages and classes @return Minimum severity level
[ "Calculates", "the", "minimum", "severity", "level", "that", "can", "output", "any", "log", "entries", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java#L209-L217
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java
TinylogLoggingProvider.calculateRequiredLogEntryValues
@SuppressWarnings("unchecked") private static Collection<LogEntryValue>[][] calculateRequiredLogEntryValues(final Collection<Writer>[][] writers) { Collection<LogEntryValue>[][] logEntryValues = new Collection[writers.length][Level.values().length - 1]; for (int tagIndex = 0; tagIndex < writers.length; ++tagIndex...
java
@SuppressWarnings("unchecked") private static Collection<LogEntryValue>[][] calculateRequiredLogEntryValues(final Collection<Writer>[][] writers) { Collection<LogEntryValue>[][] logEntryValues = new Collection[writers.length][Level.values().length - 1]; for (int tagIndex = 0; tagIndex < writers.length; ++tagIndex...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "static", "Collection", "<", "LogEntryValue", ">", "[", "]", "[", "]", "calculateRequiredLogEntryValues", "(", "final", "Collection", "<", "Writer", ">", "[", "]", "[", "]", "writers", ")", "{", ...
Creates a matrix with all required log entry values for each tag and severity level. @param writers Matrix with registered writers @return Matrix with all required log entry values
[ "Creates", "a", "matrix", "with", "all", "required", "log", "entry", "values", "for", "each", "tag", "and", "severity", "level", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java#L226-L241
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java
TinylogLoggingProvider.calculateFullStackTraceRequirements
private static BitSet calculateFullStackTraceRequirements(final Collection<LogEntryValue>[][] logEntryValues) { BitSet result = new BitSet(logEntryValues.length); for (int i = 0; i < logEntryValues.length; ++i) { Collection<LogEntryValue> values = logEntryValues[i][Level.ERROR.ordinal()]; if (values.contains(...
java
private static BitSet calculateFullStackTraceRequirements(final Collection<LogEntryValue>[][] logEntryValues) { BitSet result = new BitSet(logEntryValues.length); for (int i = 0; i < logEntryValues.length; ++i) { Collection<LogEntryValue> values = logEntryValues[i][Level.ERROR.ordinal()]; if (values.contains(...
[ "private", "static", "BitSet", "calculateFullStackTraceRequirements", "(", "final", "Collection", "<", "LogEntryValue", ">", "[", "]", "[", "]", "logEntryValues", ")", "{", "BitSet", "result", "=", "new", "BitSet", "(", "logEntryValues", ".", "length", ")", ";",...
Calculates for which tag a full stack trace element with method name, file name and line number is required. @param logEntryValues Matrix with required log entry values @return Each set bit represents a tag that requires a full stack trace element
[ "Calculates", "for", "which", "tag", "a", "full", "stack", "trace", "element", "with", "method", "name", "file", "name", "and", "line", "number", "is", "required", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java#L250-L259
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java
TinylogLoggingProvider.createWritingThread
private static WritingThread createWritingThread(final Collection<Writer>[][] matrix) { Collection<Writer> writers = getAllWriters(matrix); WritingThread thread = new WritingThread(writers); thread.start(); return thread; }
java
private static WritingThread createWritingThread(final Collection<Writer>[][] matrix) { Collection<Writer> writers = getAllWriters(matrix); WritingThread thread = new WritingThread(writers); thread.start(); return thread; }
[ "private", "static", "WritingThread", "createWritingThread", "(", "final", "Collection", "<", "Writer", ">", "[", "]", "[", "]", "matrix", ")", "{", "Collection", "<", "Writer", ">", "writers", "=", "getAllWriters", "(", "matrix", ")", ";", "WritingThread", ...
Creates a writing thread for a matrix of writers. @param matrix All writers @return Initialized and running writhing thread
[ "Creates", "a", "writing", "thread", "for", "a", "matrix", "of", "writers", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java#L268-L273
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java
TinylogLoggingProvider.getAllWriters
private static Collection<Writer> getAllWriters(final Collection<Writer>[][] matrix) { Collection<Writer> writers = Collections.newSetFromMap(new IdentityHashMap<Writer, Boolean>()); for (int i = 0; i < matrix.length; ++i) { for (int j = 0; j < matrix[i].length; ++j) { writers.addAll(matrix[i][j]); } } ...
java
private static Collection<Writer> getAllWriters(final Collection<Writer>[][] matrix) { Collection<Writer> writers = Collections.newSetFromMap(new IdentityHashMap<Writer, Boolean>()); for (int i = 0; i < matrix.length; ++i) { for (int j = 0; j < matrix[i].length; ++j) { writers.addAll(matrix[i][j]); } } ...
[ "private", "static", "Collection", "<", "Writer", ">", "getAllWriters", "(", "final", "Collection", "<", "Writer", ">", "[", "]", "[", "]", "matrix", ")", "{", "Collection", "<", "Writer", ">", "writers", "=", "Collections", ".", "newSetFromMap", "(", "new...
Collects all writer instances from a matrix of writers. @param matrix All writers @return Collection that contains each writer only once
[ "Collects", "all", "writer", "instances", "from", "a", "matrix", "of", "writers", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java#L282-L290
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java
TinylogLoggingProvider.getTagIndex
private int getTagIndex(final String tag) { if (tag == null) { return 0; } else { int index = knownTags.indexOf(tag); return index == -1 ? knownTags.size() + 1 : index + 1; } }
java
private int getTagIndex(final String tag) { if (tag == null) { return 0; } else { int index = knownTags.indexOf(tag); return index == -1 ? knownTags.size() + 1 : index + 1; } }
[ "private", "int", "getTagIndex", "(", "final", "String", "tag", ")", "{", "if", "(", "tag", "==", "null", ")", "{", "return", "0", ";", "}", "else", "{", "int", "index", "=", "knownTags", ".", "indexOf", "(", "tag", ")", ";", "return", "index", "==...
Gets the index of a tag. @param tag Name of tag @return Index of tag
[ "Gets", "the", "index", "of", "a", "tag", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java#L299-L306
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java
TinylogLoggingProvider.output
private void output(final LogEntry logEntry, final Iterable<Writer> writers) { if (writingThread == null) { for (Writer writer : writers) { try { writer.write(logEntry); } catch (Exception ex) { InternalLogger.log(Level.ERROR, ex, "Failed to write log entry '" + logEntry.getMessage() + "'"); ...
java
private void output(final LogEntry logEntry, final Iterable<Writer> writers) { if (writingThread == null) { for (Writer writer : writers) { try { writer.write(logEntry); } catch (Exception ex) { InternalLogger.log(Level.ERROR, ex, "Failed to write log entry '" + logEntry.getMessage() + "'"); ...
[ "private", "void", "output", "(", "final", "LogEntry", "logEntry", ",", "final", "Iterable", "<", "Writer", ">", "writers", ")", "{", "if", "(", "writingThread", "==", "null", ")", "{", "for", "(", "Writer", "writer", ":", "writers", ")", "{", "try", "...
Outputs a log entry to all passed writers. @param logEntry Log entry to be output @param writers All writers for outputting the passed log entry
[ "Outputs", "a", "log", "entry", "to", "all", "passed", "writers", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/TinylogLoggingProvider.java#L395-L409
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/path/DynamicPath.java
DynamicPath.getAllFiles
public List<File> getAllFiles() { List<File> files = new ArrayList<File>(); collectFiles(folder, files); Collections.sort(files, LastModifiedFileComparator.INSTANCE); return files; }
java
public List<File> getAllFiles() { List<File> files = new ArrayList<File>(); collectFiles(folder, files); Collections.sort(files, LastModifiedFileComparator.INSTANCE); return files; }
[ "public", "List", "<", "File", ">", "getAllFiles", "(", ")", "{", "List", "<", "File", ">", "files", "=", "new", "ArrayList", "<", "File", ">", "(", ")", ";", "collectFiles", "(", "folder", ",", "files", ")", ";", "Collections", ".", "sort", "(", "...
Gets all files that are compatible with the dynamic path. The returned files are sorted by the last modification date. The most recently modified files are at the top, the oldest at the bottom of the list. @return Found files
[ "Gets", "all", "files", "that", "are", "compatible", "with", "the", "dynamic", "path", ".", "The", "returned", "files", "are", "sorted", "by", "the", "last", "modification", "date", ".", "The", "most", "recently", "modified", "files", "are", "at", "the", "...
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/path/DynamicPath.java#L123-L128
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/path/DynamicPath.java
DynamicPath.collectFiles
private void collectFiles(final File folder, final List<File> found) { File[] files = folder.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { collectFiles(file, found); } else if (file.isFile() && file.getPath().endsWith(suffix)) { int index = 0; for (...
java
private void collectFiles(final File folder, final List<File> found) { File[] files = folder.listFiles(); if (files != null) { for (File file : files) { if (file.isDirectory()) { collectFiles(file, found); } else if (file.isFile() && file.getPath().endsWith(suffix)) { int index = 0; for (...
[ "private", "void", "collectFiles", "(", "final", "File", "folder", ",", "final", "List", "<", "File", ">", "found", ")", "{", "File", "[", "]", "files", "=", "folder", ".", "listFiles", "(", ")", ";", "if", "(", "files", "!=", "null", ")", "{", "fo...
Collects files from a folder and all nested sub folders. @param folder Base folder for starting search @param found All found files will be added to this list
[ "Collects", "files", "from", "a", "folder", "and", "all", "nested", "sub", "folders", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/path/DynamicPath.java#L149-L173
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/path/DynamicPath.java
DynamicPath.isValid
private boolean isValid(final String path, final int pathPosition, final int segmentIndex) { Segment segment = segments.get(segmentIndex); String expectedValue = segment.getStaticText(); if (expectedValue == null) { if (segmentIndex == segments.size() - 1) { return segment.validateToken(path.substring(path...
java
private boolean isValid(final String path, final int pathPosition, final int segmentIndex) { Segment segment = segments.get(segmentIndex); String expectedValue = segment.getStaticText(); if (expectedValue == null) { if (segmentIndex == segments.size() - 1) { return segment.validateToken(path.substring(path...
[ "private", "boolean", "isValid", "(", "final", "String", "path", ",", "final", "int", "pathPosition", ",", "final", "int", "segmentIndex", ")", "{", "Segment", "segment", "=", "segments", ".", "get", "(", "segmentIndex", ")", ";", "String", "expectedValue", ...
Checks if a partial path to a file is compatible with this dynamic path. @param path Full path to file @param pathPosition Start position for checking passed path @param segmentIndex Index of segment that will be used for check @return {@code true} if passed path is compatible, {@code false} if not
[ "Checks", "if", "a", "partial", "path", "to", "a", "file", "is", "compatible", "with", "this", "dynamic", "path", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/path/DynamicPath.java#L186-L210
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/path/DynamicPath.java
DynamicPath.parseSegment
private static Segment parseSegment(final String path, final String token) { int separator = token.indexOf(':'); String name; String parameter; if (separator == -1) { name = token.trim(); parameter = null; } else { name = token.substring(0, separator).trim(); parameter = token.substring(separato...
java
private static Segment parseSegment(final String path, final String token) { int separator = token.indexOf(':'); String name; String parameter; if (separator == -1) { name = token.trim(); parameter = null; } else { name = token.substring(0, separator).trim(); parameter = token.substring(separato...
[ "private", "static", "Segment", "parseSegment", "(", "final", "String", "path", ",", "final", "String", "token", ")", "{", "int", "separator", "=", "token", ".", "indexOf", "(", "'", "'", ")", ";", "String", "name", ";", "String", "parameter", ";", "if",...
Parses a token from a pattern as a segment. @param path Full path with patterns @param token Token from a pattern @return Created segment that represents the passed token
[ "Parses", "a", "token", "from", "a", "pattern", "as", "a", "segment", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/path/DynamicPath.java#L221-L244
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java
WritingThread.run
@Override public void run() { Collection<Writer> writers = new ArrayList<Writer>(1); while (true) { for (Task task : receiveTasks()) { if (task == Task.POISON) { close(); return; } else { write(writers, task); } } flush(writers); writers.clear(); try { sleep(MILLISE...
java
@Override public void run() { Collection<Writer> writers = new ArrayList<Writer>(1); while (true) { for (Task task : receiveTasks()) { if (task == Task.POISON) { close(); return; } else { write(writers, task); } } flush(writers); writers.clear(); try { sleep(MILLISE...
[ "@", "Override", "public", "void", "run", "(", ")", "{", "Collection", "<", "Writer", ">", "writers", "=", "new", "ArrayList", "<", "Writer", ">", "(", "1", ")", ";", "while", "(", "true", ")", "{", "for", "(", "Task", "task", ":", "receiveTasks", ...
Fetches log entries and writes them until receiving a poison task.
[ "Fetches", "log", "entries", "and", "writes", "them", "until", "receiving", "a", "poison", "task", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java#L54-L77
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java
WritingThread.add
void add(final Writer writer, final LogEntry logEntry) { Task task = new Task(writer, logEntry); synchronized (mutex) { tasks.add(task); } }
java
void add(final Writer writer, final LogEntry logEntry) { Task task = new Task(writer, logEntry); synchronized (mutex) { tasks.add(task); } }
[ "void", "add", "(", "final", "Writer", "writer", ",", "final", "LogEntry", "logEntry", ")", "{", "Task", "task", "=", "new", "Task", "(", "writer", ",", "logEntry", ")", ";", "synchronized", "(", "mutex", ")", "{", "tasks", ".", "add", "(", "task", "...
Adds a log entry for writing. @param writer Writer to write given log entry @param logEntry Log entry to write
[ "Adds", "a", "log", "entry", "for", "writing", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java#L87-L92
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java
WritingThread.receiveTasks
private List<Task> receiveTasks() { synchronized (mutex) { if (tasks.isEmpty()) { return Collections.emptyList(); } else { List<Task> currentTasks = tasks; tasks = new ArrayList<Task>(); return currentTasks; } } }
java
private List<Task> receiveTasks() { synchronized (mutex) { if (tasks.isEmpty()) { return Collections.emptyList(); } else { List<Task> currentTasks = tasks; tasks = new ArrayList<Task>(); return currentTasks; } } }
[ "private", "List", "<", "Task", ">", "receiveTasks", "(", ")", "{", "synchronized", "(", "mutex", ")", "{", "if", "(", "tasks", ".", "isEmpty", "(", ")", ")", "{", "return", "Collections", ".", "emptyList", "(", ")", ";", "}", "else", "{", "List", ...
Receives all added log entries. @return Log entries to write
[ "Receives", "all", "added", "log", "entries", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java#L115-L125
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java
WritingThread.write
private void write(final Collection<Writer> writers, final Task task) { try { Writer writer = task.writer; writer.write(task.logEntry); if (!writers.contains(writer)) { writers.add(writer); } } catch (Exception ex) { InternalLogger.log(Level.ERROR, ex, "Failed to write log entry '" + task.logEntr...
java
private void write(final Collection<Writer> writers, final Task task) { try { Writer writer = task.writer; writer.write(task.logEntry); if (!writers.contains(writer)) { writers.add(writer); } } catch (Exception ex) { InternalLogger.log(Level.ERROR, ex, "Failed to write log entry '" + task.logEntr...
[ "private", "void", "write", "(", "final", "Collection", "<", "Writer", ">", "writers", ",", "final", "Task", "task", ")", "{", "try", "{", "Writer", "writer", "=", "task", ".", "writer", ";", "writer", ".", "write", "(", "task", ".", "logEntry", ")", ...
Writes a log entry. @param writers Mutable collection of used writers @param task Log entry to write
[ "Writes", "a", "log", "entry", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java#L135-L145
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java
WritingThread.flush
private void flush(final Collection<Writer> writers) { for (Writer writer : writers) { try { writer.flush(); } catch (Exception ex) { InternalLogger.log(Level.ERROR, ex, "Failed to flush writer"); } } }
java
private void flush(final Collection<Writer> writers) { for (Writer writer : writers) { try { writer.flush(); } catch (Exception ex) { InternalLogger.log(Level.ERROR, ex, "Failed to flush writer"); } } }
[ "private", "void", "flush", "(", "final", "Collection", "<", "Writer", ">", "writers", ")", "{", "for", "(", "Writer", "writer", ":", "writers", ")", "{", "try", "{", "writer", ".", "flush", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", ...
Flushes a collection of writers. @param writers Writers to flush
[ "Flushes", "a", "collection", "of", "writers", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java#L153-L161
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java
WritingThread.close
private void close() { for (Writer writer : writers) { try { writer.close(); } catch (Exception ex) { InternalLogger.log(Level.ERROR, ex, "Failed to close writer"); } } }
java
private void close() { for (Writer writer : writers) { try { writer.close(); } catch (Exception ex) { InternalLogger.log(Level.ERROR, ex, "Failed to close writer"); } } }
[ "private", "void", "close", "(", ")", "{", "for", "(", "Writer", "writer", ":", "writers", ")", "{", "try", "{", "writer", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "ex", ")", "{", "InternalLogger", ".", "log", "(", "Level", ".",...
Closes all writers.
[ "Closes", "all", "writers", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/WritingThread.java#L166-L174
train
pmwmedia/tinylog
benchmarks/src/main/java/org/tinylog/benchmarks/converters/HtmlDiagramRenderer.java
HtmlDiagramRenderer.output
public void output(final Map<String, Map<String, List<BigDecimal>>> benchmarks) { for (Entry<String, Map<String, List<BigDecimal>>> benchmark : benchmarks.entrySet()) { BigDecimal max = benchmark.getValue().values().stream() .flatMap(list -> list.stream()) .max(Comparator.naturalOrder()) .orElse(BigDec...
java
public void output(final Map<String, Map<String, List<BigDecimal>>> benchmarks) { for (Entry<String, Map<String, List<BigDecimal>>> benchmark : benchmarks.entrySet()) { BigDecimal max = benchmark.getValue().values().stream() .flatMap(list -> list.stream()) .max(Comparator.naturalOrder()) .orElse(BigDec...
[ "public", "void", "output", "(", "final", "Map", "<", "String", ",", "Map", "<", "String", ",", "List", "<", "BigDecimal", ">", ">", ">", "benchmarks", ")", "{", "for", "(", "Entry", "<", "String", ",", "Map", "<", "String", ",", "List", "<", "BigD...
Creates and outputs HTML diagrams. @param benchmarks Results of logging framework benchmarks
[ "Creates", "and", "outputs", "HTML", "diagrams", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/benchmarks/src/main/java/org/tinylog/benchmarks/converters/HtmlDiagramRenderer.java#L50-L95
train
pmwmedia/tinylog
log4j1.2-api/src/main/java/org/apache/log4j/LogManager.java
LogManager.getCurrentLoggers
@SuppressWarnings("rawtypes") public static Enumeration getCurrentLoggers() { ArrayList<Logger> copy; synchronized (mutex) { copy = new ArrayList<Logger>(loggers.values()); } copy.remove(root); return Collections.enumeration(copy); }
java
@SuppressWarnings("rawtypes") public static Enumeration getCurrentLoggers() { ArrayList<Logger> copy; synchronized (mutex) { copy = new ArrayList<Logger>(loggers.values()); } copy.remove(root); return Collections.enumeration(copy); }
[ "@", "SuppressWarnings", "(", "\"rawtypes\"", ")", "public", "static", "Enumeration", "getCurrentLoggers", "(", ")", "{", "ArrayList", "<", "Logger", ">", "copy", ";", "synchronized", "(", "mutex", ")", "{", "copy", "=", "new", "ArrayList", "<", "Logger", ">...
Retrieves all existing loggers. @return Enumeration with all existing loggers
[ "Retrieves", "all", "existing", "loggers", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/log4j1.2-api/src/main/java/org/apache/log4j/LogManager.java#L111-L119
train
pmwmedia/tinylog
log4j1.2-api/src/main/java/org/apache/log4j/LogManager.java
LogManager.getOrCreateLogger
private static Logger getOrCreateLogger(final String name) { if (name == null || name.length() == 0) { return root; } else { Logger logger = loggers.get(name); if (logger == null) { Logger parent = getOrCreateLogger(reduce(name)); logger = new Logger(parent, name); loggers.put(name, logger); ...
java
private static Logger getOrCreateLogger(final String name) { if (name == null || name.length() == 0) { return root; } else { Logger logger = loggers.get(name); if (logger == null) { Logger parent = getOrCreateLogger(reduce(name)); logger = new Logger(parent, name); loggers.put(name, logger); ...
[ "private", "static", "Logger", "getOrCreateLogger", "(", "final", "String", "name", ")", "{", "if", "(", "name", "==", "null", "||", "name", ".", "length", "(", ")", "==", "0", ")", "{", "return", "root", ";", "}", "else", "{", "Logger", "logger", "=...
Retrieves a logger by name. @param name Name of the logger @return Logger instance
[ "Retrieves", "a", "logger", "by", "name", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/log4j1.2-api/src/main/java/org/apache/log4j/LogManager.java#L153-L165
train
pmwmedia/tinylog
log4j1.2-api/src/main/java/org/apache/log4j/LogManager.java
LogManager.reduce
private static String reduce(final String name) { int index = name.lastIndexOf('.'); return index == -1 ? null : name.substring(0, index); }
java
private static String reduce(final String name) { int index = name.lastIndexOf('.'); return index == -1 ? null : name.substring(0, index); }
[ "private", "static", "String", "reduce", "(", "final", "String", "name", ")", "{", "int", "index", "=", "name", ".", "lastIndexOf", "(", "'", "'", ")", ";", "return", "index", "==", "-", "1", "?", "null", ":", "name", ".", "substring", "(", "0", ",...
Gets the parent's logger name for a given logger name. @param name Logger name @return Logger name of parent
[ "Gets", "the", "parent", "s", "logger", "name", "for", "a", "given", "logger", "name", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/log4j1.2-api/src/main/java/org/apache/log4j/LogManager.java#L174-L177
train
pmwmedia/tinylog
log4j1.2-api/src/main/java/org/apache/log4j/Logger.java
Logger.isTraceEnabled
public boolean isTraceEnabled() { return MINIMUM_LEVEL_COVERS_TRACE && provider.isEnabled(STACKTRACE_DEPTH, null, org.tinylog.Level.TRACE); }
java
public boolean isTraceEnabled() { return MINIMUM_LEVEL_COVERS_TRACE && provider.isEnabled(STACKTRACE_DEPTH, null, org.tinylog.Level.TRACE); }
[ "public", "boolean", "isTraceEnabled", "(", ")", "{", "return", "MINIMUM_LEVEL_COVERS_TRACE", "&&", "provider", ".", "isEnabled", "(", "STACKTRACE_DEPTH", ",", "null", ",", "org", ".", "tinylog", ".", "Level", ".", "TRACE", ")", ";", "}" ]
Check whether this category is enabled for the TRACE Level. @return boolean - {@code true} if this category is enabled for level TRACE, {@code false} otherwise. @since 1.2.12
[ "Check", "whether", "this", "category", "is", "enabled", "for", "the", "TRACE", "Level", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/log4j1.2-api/src/main/java/org/apache/log4j/Logger.java#L159-L161
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/configuration/ServiceLoader.java
ServiceLoader.create
public T create(final String name, final Object... arguments) { if (name.indexOf('.') == -1) { String expectingClassName = toSimpleClassName(name); for (String className : classes) { int split = className.lastIndexOf('.'); String simpleClassName = split == -1 ? className : className.substring(split + 1)...
java
public T create(final String name, final Object... arguments) { if (name.indexOf('.') == -1) { String expectingClassName = toSimpleClassName(name); for (String className : classes) { int split = className.lastIndexOf('.'); String simpleClassName = split == -1 ? className : className.substring(split + 1)...
[ "public", "T", "create", "(", "final", "String", "name", ",", "final", "Object", "...", "arguments", ")", "{", "if", "(", "name", ".", "indexOf", "(", "'", "'", ")", "==", "-", "1", ")", "{", "String", "expectingClassName", "=", "toSimpleClassName", "(...
Creates a defined service implementation. The name can be either the fully-qualified class name or the simplified acronym. The acronym is the class name without package and service suffix. <p> The acronym for {@code org.tinylog.writers.RollingFileWriter} is for example {@code rolling file}. </p> @param name Acronym o...
[ "Creates", "a", "defined", "service", "implementation", ".", "The", "name", "can", "be", "either", "the", "fully", "-", "qualified", "class", "name", "or", "the", "simplified", "acronym", ".", "The", "acronym", "is", "the", "class", "name", "without", "packa...
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/configuration/ServiceLoader.java#L75-L91
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/configuration/ServiceLoader.java
ServiceLoader.createAll
public Collection<T> createAll(final Object... arguments) { Collection<T> instances = new ArrayList<T>(classes.size()); for (String className : classes) { T instance = createInstance(className, arguments); if (instance != null) { instances.add(instance); } } return instances; }
java
public Collection<T> createAll(final Object... arguments) { Collection<T> instances = new ArrayList<T>(classes.size()); for (String className : classes) { T instance = createInstance(className, arguments); if (instance != null) { instances.add(instance); } } return instances; }
[ "public", "Collection", "<", "T", ">", "createAll", "(", "final", "Object", "...", "arguments", ")", "{", "Collection", "<", "T", ">", "instances", "=", "new", "ArrayList", "<", "T", ">", "(", "classes", ".", "size", "(", ")", ")", ";", "for", "(", ...
Creates all registered service implementations. @param arguments Arguments for constructors of service implementations @return Instances of all service implementations
[ "Creates", "all", "registered", "service", "implementations", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/configuration/ServiceLoader.java#L100-L111
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/configuration/ServiceLoader.java
ServiceLoader.loadClasses
private static <T> Collection<String> loadClasses(final ClassLoader classLoader, final Class<? extends T> service) { String name = SERVICE_PREFIX + service.getName(); Enumeration<URL> urls; try { urls = classLoader.getResources(name); } catch (IOException ex) { InternalLogger.log(Level.ERROR, "Failed load...
java
private static <T> Collection<String> loadClasses(final ClassLoader classLoader, final Class<? extends T> service) { String name = SERVICE_PREFIX + service.getName(); Enumeration<URL> urls; try { urls = classLoader.getResources(name); } catch (IOException ex) { InternalLogger.log(Level.ERROR, "Failed load...
[ "private", "static", "<", "T", ">", "Collection", "<", "String", ">", "loadClasses", "(", "final", "ClassLoader", "classLoader", ",", "final", "Class", "<", "?", "extends", "T", ">", "service", ")", "{", "String", "name", "=", "SERVICE_PREFIX", "+", "servi...
Loads all registered service class names. @param <T> Service interface @param classLoader Class loader to use for finding service files @param service Service interface @return Class names
[ "Loads", "all", "registered", "service", "class", "names", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/configuration/ServiceLoader.java#L124-L162
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/configuration/ServiceLoader.java
ServiceLoader.toSimpleClassName
private String toSimpleClassName(final String name) { StringBuilder builder = new StringBuilder(name.length()); for (String token : SPLIT_PATTERN.split(name)) { if (!token.isEmpty()) { builder.append(Character.toUpperCase(token.charAt(0))); builder.append(token.substring(1).toLowerCase(Locale.ROOT)); ...
java
private String toSimpleClassName(final String name) { StringBuilder builder = new StringBuilder(name.length()); for (String token : SPLIT_PATTERN.split(name)) { if (!token.isEmpty()) { builder.append(Character.toUpperCase(token.charAt(0))); builder.append(token.substring(1).toLowerCase(Locale.ROOT)); ...
[ "private", "String", "toSimpleClassName", "(", "final", "String", "name", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", "name", ".", "length", "(", ")", ")", ";", "for", "(", "String", "token", ":", "SPLIT_PATTERN", ".", "split", ...
Generates the simple class name from an acronym. A simple class name is the class name without package. <p> The acronym {@code rolling file}, for example, will be transformed into {@code RollingFileWriter} for the service interface {@code Writer}. </p> @param name Simplified acronym @return Simple class without packa...
[ "Generates", "the", "simple", "class", "name", "from", "an", "acronym", ".", "A", "simple", "class", "name", "is", "the", "class", "name", "without", "package", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/configuration/ServiceLoader.java#L176-L186
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/configuration/ServiceLoader.java
ServiceLoader.createInstance
@SuppressWarnings("unchecked") private T createInstance(final String className, final Object... arguments) { try { Class<?> implementation = Class.forName(className, false, classLoader); if (service.isAssignableFrom(implementation)) { return (T) implementation.getDeclaredConstructor(argumentTypes).newInsta...
java
@SuppressWarnings("unchecked") private T createInstance(final String className, final Object... arguments) { try { Class<?> implementation = Class.forName(className, false, classLoader); if (service.isAssignableFrom(implementation)) { return (T) implementation.getDeclaredConstructor(argumentTypes).newInsta...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "T", "createInstance", "(", "final", "String", "className", ",", "final", "Object", "...", "arguments", ")", "{", "try", "{", "Class", "<", "?", ">", "implementation", "=", "Class", ".", "forName...
Creates a new instance of a class. @param className Fully-qualified class name @param arguments Arguments for constructor @return A new instance of given class or {@code null} if creation failed
[ "Creates", "a", "new", "instance", "of", "a", "class", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/configuration/ServiceLoader.java#L197-L221
train
pmwmedia/tinylog
benchmarks/src/main/java/org/tinylog/benchmarks/converters/Framework.java
Framework.getVersion
private static String getVersion(final Class<?> clazz) { CodeSource source = clazz.getProtectionDomain().getCodeSource(); URL location = source.getLocation(); try { Path path = Paths.get(location.toURI()); return Files.isRegularFile(path) ? getVersionFromJar(path) : getVersionFromPom(path); } catch (URIS...
java
private static String getVersion(final Class<?> clazz) { CodeSource source = clazz.getProtectionDomain().getCodeSource(); URL location = source.getLocation(); try { Path path = Paths.get(location.toURI()); return Files.isRegularFile(path) ? getVersionFromJar(path) : getVersionFromPom(path); } catch (URIS...
[ "private", "static", "String", "getVersion", "(", "final", "Class", "<", "?", ">", "clazz", ")", "{", "CodeSource", "source", "=", "clazz", ".", "getProtectionDomain", "(", ")", ".", "getCodeSource", "(", ")", ";", "URL", "location", "=", "source", ".", ...
Gets the version for a class. @param clazz Class for which the version should be determined @return Found version or {@code null}
[ "Gets", "the", "version", "for", "a", "class", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/benchmarks/src/main/java/org/tinylog/benchmarks/converters/Framework.java#L114-L125
train
pmwmedia/tinylog
benchmarks/src/main/java/org/tinylog/benchmarks/converters/Framework.java
Framework.getVersionFromJar
private static String getVersionFromJar(final Path path) { Matcher matcher = JAR_VERSION.matcher(path.toString()); if (matcher.matches()) { return matcher.group(1); } else { Logger.error("JAR file \"{}\" does not contain a version", path); return null; } }
java
private static String getVersionFromJar(final Path path) { Matcher matcher = JAR_VERSION.matcher(path.toString()); if (matcher.matches()) { return matcher.group(1); } else { Logger.error("JAR file \"{}\" does not contain a version", path); return null; } }
[ "private", "static", "String", "getVersionFromJar", "(", "final", "Path", "path", ")", "{", "Matcher", "matcher", "=", "JAR_VERSION", ".", "matcher", "(", "path", ".", "toString", "(", ")", ")", ";", "if", "(", "matcher", ".", "matches", "(", ")", ")", ...
Gets the version for a JAR file. @param path Path to JAR file @return Found version or {@code null}
[ "Gets", "the", "version", "for", "a", "JAR", "file", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/benchmarks/src/main/java/org/tinylog/benchmarks/converters/Framework.java#L134-L142
train
pmwmedia/tinylog
benchmarks/src/main/java/org/tinylog/benchmarks/converters/Framework.java
Framework.getVersionFromPom
private static String getVersionFromPom(final Path path) { Path folder = path; Path file; while (true) { file = folder.resolve("pom.xml"); if (Files.exists(file)) { break; } folder = folder.getParent(); if (folder == null) { Logger.error("pom.xml is missing for \"{}\"", path); return ...
java
private static String getVersionFromPom(final Path path) { Path folder = path; Path file; while (true) { file = folder.resolve("pom.xml"); if (Files.exists(file)) { break; } folder = folder.getParent(); if (folder == null) { Logger.error("pom.xml is missing for \"{}\"", path); return ...
[ "private", "static", "String", "getVersionFromPom", "(", "final", "Path", "path", ")", "{", "Path", "folder", "=", "path", ";", "Path", "file", ";", "while", "(", "true", ")", "{", "file", "=", "folder", ".", "resolve", "(", "\"pom.xml\"", ")", ";", "i...
Gets the version for a folder by searching for a pom.xml in the folder and its folders. @param path Path to a folder @return Found version or {@code null}
[ "Gets", "the", "version", "for", "a", "folder", "by", "searching", "for", "a", "pom", ".", "xml", "in", "the", "folder", "and", "its", "folders", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/benchmarks/src/main/java/org/tinylog/benchmarks/converters/Framework.java#L151-L183
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/runtime/AndroidRuntime.java
AndroidRuntime.findStackTraceElement
private static StackTraceElement findStackTraceElement(final String loggerClassName, final StackTraceElement[] trace) { int index = 0; while (index < trace.length && !loggerClassName.equals(trace[index].getClassName())) { index = index + 1; } while (index < trace.length && loggerClassName.equals(trace[...
java
private static StackTraceElement findStackTraceElement(final String loggerClassName, final StackTraceElement[] trace) { int index = 0; while (index < trace.length && !loggerClassName.equals(trace[index].getClassName())) { index = index + 1; } while (index < trace.length && loggerClassName.equals(trace[...
[ "private", "static", "StackTraceElement", "findStackTraceElement", "(", "final", "String", "loggerClassName", ",", "final", "StackTraceElement", "[", "]", "trace", ")", "{", "int", "index", "=", "0", ";", "while", "(", "index", "<", "trace", ".", "length", "&&...
Gets the stack trace element that appears before the passed logger class name. @param loggerClassName Logger class name that should appear before the expected stack trace element @param trace Source stack trace @return Found stack trace element or {@code null}
[ "Gets", "the", "stack", "trace", "element", "that", "appears", "before", "the", "passed", "logger", "class", "name", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/runtime/AndroidRuntime.java#L134-L150
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/runtime/AndroidRuntime.java
AndroidRuntime.extractCallerStackTraceElements
private StackTraceElement[] extractCallerStackTraceElements(final int count) { if (stackTraceElementsFiller != null) { try { StackTraceElement[] trace = new StackTraceElement[count + 1]; stackTraceElementsFiller.invoke(null, Thread.currentThread(), trace); return trace; } catch (IllegalAccessExcepti...
java
private StackTraceElement[] extractCallerStackTraceElements(final int count) { if (stackTraceElementsFiller != null) { try { StackTraceElement[] trace = new StackTraceElement[count + 1]; stackTraceElementsFiller.invoke(null, Thread.currentThread(), trace); return trace; } catch (IllegalAccessExcepti...
[ "private", "StackTraceElement", "[", "]", "extractCallerStackTraceElements", "(", "final", "int", "count", ")", "{", "if", "(", "stackTraceElementsFiller", "!=", "null", ")", "{", "try", "{", "StackTraceElement", "[", "]", "trace", "=", "new", "StackTraceElement",...
Extracts a defined number of elements from stack trace. @param count Number of stack trace elements to extract @return Extracted stack trace elements
[ "Extracts", "a", "defined", "number", "of", "elements", "from", "stack", "trace", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/runtime/AndroidRuntime.java#L159-L173
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/Logger.java
Logger.tag
public static TaggedLogger tag(final String tag) { if (tag == null || tag.isEmpty()) { return instance; } else { TaggedLogger logger = loggers.get(tag); if (logger == null) { logger = new TaggedLogger(tag); TaggedLogger existing = loggers.putIfAbsent(tag, logger); return existing == null ? logg...
java
public static TaggedLogger tag(final String tag) { if (tag == null || tag.isEmpty()) { return instance; } else { TaggedLogger logger = loggers.get(tag); if (logger == null) { logger = new TaggedLogger(tag); TaggedLogger existing = loggers.putIfAbsent(tag, logger); return existing == null ? logg...
[ "public", "static", "TaggedLogger", "tag", "(", "final", "String", "tag", ")", "{", "if", "(", "tag", "==", "null", "||", "tag", ".", "isEmpty", "(", ")", ")", "{", "return", "instance", ";", "}", "else", "{", "TaggedLogger", "logger", "=", "loggers", ...
Gets a tagged logger instance. Tags are case-sensitive. @param tag Tag for logger or {@code null} for receiving an untagged logger @return Logger instance
[ "Gets", "a", "tagged", "logger", "instance", ".", "Tags", "are", "case", "-", "sensitive", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/Logger.java#L53-L66
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/runtime/ModernJavaRuntime.java
ModernJavaRuntime.getCurrentProcess
private static ProcessHandle getCurrentProcess() { try { return (ProcessHandle) ProcessHandle.class.getDeclaredMethod("current").invoke(null); } catch (ReflectiveOperationException ex) { InternalLogger.log(Level.ERROR, ex, "Failed to receive the handle of the current process"); return null; } }
java
private static ProcessHandle getCurrentProcess() { try { return (ProcessHandle) ProcessHandle.class.getDeclaredMethod("current").invoke(null); } catch (ReflectiveOperationException ex) { InternalLogger.log(Level.ERROR, ex, "Failed to receive the handle of the current process"); return null; } }
[ "private", "static", "ProcessHandle", "getCurrentProcess", "(", ")", "{", "try", "{", "return", "(", "ProcessHandle", ")", "ProcessHandle", ".", "class", ".", "getDeclaredMethod", "(", "\"current\"", ")", ".", "invoke", "(", "null", ")", ";", "}", "catch", "...
Gets the process handle of the current process. @return Process handle of current process
[ "Gets", "the", "process", "handle", "of", "the", "current", "process", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/runtime/ModernJavaRuntime.java#L78-L85
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/pattern/ExceptionToken.java
ExceptionToken.render
private static void render(final Throwable throwable, final StringBuilder builder) { builder.append(throwable.getClass().getName()); String message = throwable.getMessage(); if (message != null) { builder.append(": "); builder.append(message); } StackTraceElement[] stackTrace = throwable.getStackTrace(...
java
private static void render(final Throwable throwable, final StringBuilder builder) { builder.append(throwable.getClass().getName()); String message = throwable.getMessage(); if (message != null) { builder.append(": "); builder.append(message); } StackTraceElement[] stackTrace = throwable.getStackTrace(...
[ "private", "static", "void", "render", "(", "final", "Throwable", "throwable", ",", "final", "StringBuilder", "builder", ")", "{", "builder", ".", "append", "(", "throwable", ".", "getClass", "(", ")", ".", "getName", "(", ")", ")", ";", "String", "message...
Renders a throwable including stack trace and cause throwables. @param throwable Throwable to render @param builder Output will be appended to this string builder
[ "Renders", "a", "throwable", "including", "stack", "trace", "and", "cause", "throwables", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/pattern/ExceptionToken.java#L68-L89
train
pmwmedia/tinylog
benchmarks/src/main/java/org/tinylog/benchmarks/converters/HtmlConverterApplication.java
HtmlConverterApplication.main
public static void main(final String[] args) { BenchmarkOutputParser parser = new BenchmarkOutputParser(FRAMEWORKS.keySet()); HtmlDiagramRenderer renderer = new HtmlDiagramRenderer(FRAMEWORKS); renderer.output(parser.parse(OUTPUT_FILE)); }
java
public static void main(final String[] args) { BenchmarkOutputParser parser = new BenchmarkOutputParser(FRAMEWORKS.keySet()); HtmlDiagramRenderer renderer = new HtmlDiagramRenderer(FRAMEWORKS); renderer.output(parser.parse(OUTPUT_FILE)); }
[ "public", "static", "void", "main", "(", "final", "String", "[", "]", "args", ")", "{", "BenchmarkOutputParser", "parser", "=", "new", "BenchmarkOutputParser", "(", "FRAMEWORKS", ".", "keySet", "(", ")", ")", ";", "HtmlDiagramRenderer", "renderer", "=", "new",...
Main method for executing the converter. @param args Arguments are ignored
[ "Main", "method", "for", "executing", "the", "converter", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/benchmarks/src/main/java/org/tinylog/benchmarks/converters/HtmlConverterApplication.java#L46-L50
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/AbstractFormatPatternWriter.java
AbstractFormatPatternWriter.getFileName
protected static String getFileName(final Map<String, String> properties) { String fileName = properties.get("file"); if (fileName == null) { throw new IllegalArgumentException("File name is missing for file writer"); } else { return fileName; } }
java
protected static String getFileName(final Map<String, String> properties) { String fileName = properties.get("file"); if (fileName == null) { throw new IllegalArgumentException("File name is missing for file writer"); } else { return fileName; } }
[ "protected", "static", "String", "getFileName", "(", "final", "Map", "<", "String", ",", "String", ">", "properties", ")", "{", "String", "fileName", "=", "properties", ".", "get", "(", "\"file\"", ")", ";", "if", "(", "fileName", "==", "null", ")", "{",...
Extracts the log file name from configuration. @param properties Configuration for writer @return Log file name @throws IllegalArgumentException Log file is not defined in configuration
[ "Extracts", "the", "log", "file", "name", "from", "configuration", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/AbstractFormatPatternWriter.java#L81-L88
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/AbstractFormatPatternWriter.java
AbstractFormatPatternWriter.getCharset
protected static Charset getCharset(final Map<String, String> properties) { String charsetName = properties.get("charset"); try { return charsetName == null ? Charset.defaultCharset() : Charset.forName(charsetName); } catch (IllegalArgumentException ex) { InternalLogger.log(Level.ERROR, "Invalid charset: " ...
java
protected static Charset getCharset(final Map<String, String> properties) { String charsetName = properties.get("charset"); try { return charsetName == null ? Charset.defaultCharset() : Charset.forName(charsetName); } catch (IllegalArgumentException ex) { InternalLogger.log(Level.ERROR, "Invalid charset: " ...
[ "protected", "static", "Charset", "getCharset", "(", "final", "Map", "<", "String", ",", "String", ">", "properties", ")", "{", "String", "charsetName", "=", "properties", ".", "get", "(", "\"charset\"", ")", ";", "try", "{", "return", "charsetName", "==", ...
Extracts the charset from configuration. The default charset will be returned, if no charset is defined or the defined charset doesn't exist. @param properties Configuration for writer @return Configured charset
[ "Extracts", "the", "charset", "from", "configuration", ".", "The", "default", "charset", "will", "be", "returned", "if", "no", "charset", "is", "defined", "or", "the", "defined", "charset", "doesn", "t", "exist", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/AbstractFormatPatternWriter.java#L98-L106
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/AbstractFormatPatternWriter.java
AbstractFormatPatternWriter.render
protected final String render(final LogEntry logEntry) { if (builder == null) { StringBuilder builder = new StringBuilder(BUILDER_CAPACITY); token.render(logEntry, builder); return builder.toString(); } else { builder.setLength(0); token.render(logEntry, builder); return builder.toString(); } }
java
protected final String render(final LogEntry logEntry) { if (builder == null) { StringBuilder builder = new StringBuilder(BUILDER_CAPACITY); token.render(logEntry, builder); return builder.toString(); } else { builder.setLength(0); token.render(logEntry, builder); return builder.toString(); } }
[ "protected", "final", "String", "render", "(", "final", "LogEntry", "logEntry", ")", "{", "if", "(", "builder", "==", "null", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", "BUILDER_CAPACITY", ")", ";", "token", ".", "render", "(", ...
Renders a log entry as string. @param logEntry Log entry to render @return Rendered log entry
[ "Renders", "a", "log", "entry", "as", "string", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/AbstractFormatPatternWriter.java#L151-L161
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/RollingFileWriter.java
RollingFileWriter.internalWrite
private void internalWrite(final byte[] data) throws IOException { if (!canBeContinued(data, policies)) { writer.close(); String fileName = path.resolve(); deleteBackups(path.getAllFiles(), backups); writer = createByteArrayWriter(fileName, false, buffered, false, false); for (Policy policy : policie...
java
private void internalWrite(final byte[] data) throws IOException { if (!canBeContinued(data, policies)) { writer.close(); String fileName = path.resolve(); deleteBackups(path.getAllFiles(), backups); writer = createByteArrayWriter(fileName, false, buffered, false, false); for (Policy policy : policie...
[ "private", "void", "internalWrite", "(", "final", "byte", "[", "]", "data", ")", "throws", "IOException", "{", "if", "(", "!", "canBeContinued", "(", "data", ",", "policies", ")", ")", "{", "writer", ".", "close", "(", ")", ";", "String", "fileName", "...
Outputs a passed byte array unsynchronized. @param data Byte array to output @throws IOException Writing failed
[ "Outputs", "a", "passed", "byte", "array", "unsynchronized", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/RollingFileWriter.java#L134-L148
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/RollingFileWriter.java
RollingFileWriter.createPolicies
private static List<Policy> createPolicies(final String property) { if (property == null || property.isEmpty()) { return Collections.<Policy>singletonList(new StartupPolicy(null)); } else { ServiceLoader<Policy> loader = new ServiceLoader<Policy>(Policy.class, String.class); List<Policy> policies = new Arr...
java
private static List<Policy> createPolicies(final String property) { if (property == null || property.isEmpty()) { return Collections.<Policy>singletonList(new StartupPolicy(null)); } else { ServiceLoader<Policy> loader = new ServiceLoader<Policy>(Policy.class, String.class); List<Policy> policies = new Arr...
[ "private", "static", "List", "<", "Policy", ">", "createPolicies", "(", "final", "String", "property", ")", "{", "if", "(", "property", "==", "null", "||", "property", ".", "isEmpty", "(", ")", ")", "{", "return", "Collections", ".", "<", "Policy", ">", ...
Creates policies from a nullable string. @param property Nullable string with policies to create @return Created policies
[ "Creates", "policies", "from", "a", "nullable", "string", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/RollingFileWriter.java#L177-L195
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/RollingFileWriter.java
RollingFileWriter.canBeContinued
private static boolean canBeContinued(final String fileName, final List<Policy> policies) { boolean result = true; for (Policy policy : policies) { result &= policy.continueExistingFile(fileName); } return result; }
java
private static boolean canBeContinued(final String fileName, final List<Policy> policies) { boolean result = true; for (Policy policy : policies) { result &= policy.continueExistingFile(fileName); } return result; }
[ "private", "static", "boolean", "canBeContinued", "(", "final", "String", "fileName", ",", "final", "List", "<", "Policy", ">", "policies", ")", "{", "boolean", "result", "=", "true", ";", "for", "(", "Policy", "policy", ":", "policies", ")", "{", "result"...
Checks if an already existing log file can be continued. @param fileName Log file @param policies Policies that should be applied @return {@code true} if the passed log file can be continued, {@code false} if a new log file should be started
[ "Checks", "if", "an", "already", "existing", "log", "file", "can", "be", "continued", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/RollingFileWriter.java#L206-L212
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/RollingFileWriter.java
RollingFileWriter.canBeContinued
private static boolean canBeContinued(final byte[] data, final List<Policy> policies) { boolean result = true; for (Policy policy : policies) { result &= policy.continueCurrentFile(data); } return result; }
java
private static boolean canBeContinued(final byte[] data, final List<Policy> policies) { boolean result = true; for (Policy policy : policies) { result &= policy.continueCurrentFile(data); } return result; }
[ "private", "static", "boolean", "canBeContinued", "(", "final", "byte", "[", "]", "data", ",", "final", "List", "<", "Policy", ">", "policies", ")", "{", "boolean", "result", "=", "true", ";", "for", "(", "Policy", "policy", ":", "policies", ")", "{", ...
Checks if a new log entry can be still written to the current log file. @param data Log entry @param policies Policies that should be applied @return {@code true} if the current log file can be continued, {@code false} if a new log file should be started
[ "Checks", "if", "a", "new", "log", "entry", "can", "be", "still", "written", "to", "the", "current", "log", "file", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/RollingFileWriter.java#L223-L229
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/RollingFileWriter.java
RollingFileWriter.deleteBackups
private static void deleteBackups(final List<File> files, final int count) { if (count >= 0) { for (int i = files.size() - Math.max(0, files.size() - count); i < files.size(); ++i) { if (!files.get(i).delete()) { InternalLogger.log(Level.WARN, "Failed to delete log file '" + files.get(i).getAbsolutePath()...
java
private static void deleteBackups(final List<File> files, final int count) { if (count >= 0) { for (int i = files.size() - Math.max(0, files.size() - count); i < files.size(); ++i) { if (!files.get(i).delete()) { InternalLogger.log(Level.WARN, "Failed to delete log file '" + files.get(i).getAbsolutePath()...
[ "private", "static", "void", "deleteBackups", "(", "final", "List", "<", "File", ">", "files", ",", "final", "int", "count", ")", "{", "if", "(", "count", ">=", "0", ")", "{", "for", "(", "int", "i", "=", "files", ".", "size", "(", ")", "-", "Mat...
Deletes old log files. @param files All existing log files @param count Number of log files to keep
[ "Deletes", "old", "log", "files", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/RollingFileWriter.java#L239-L247
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/policies/SizePolicy.java
SizePolicy.parse
private static long parse(final String argument) throws NumberFormatException { if (argument.endsWith("gb")) { return Long.parseLong(argument.substring(0, argument.length() - "gb".length()).trim()) * GB; } else if (argument.endsWith("mb")) { return Long.parseLong(argument.substring(0, argument.length() - "mb"...
java
private static long parse(final String argument) throws NumberFormatException { if (argument.endsWith("gb")) { return Long.parseLong(argument.substring(0, argument.length() - "gb".length()).trim()) * GB; } else if (argument.endsWith("mb")) { return Long.parseLong(argument.substring(0, argument.length() - "mb"...
[ "private", "static", "long", "parse", "(", "final", "String", "argument", ")", "throws", "NumberFormatException", "{", "if", "(", "argument", ".", "endsWith", "(", "\"gb\"", ")", ")", "{", "return", "Long", ".", "parseLong", "(", "argument", ".", "substring"...
Parses file size from a string. The units GB, MB, KB and bytes are supported. @param argument Lower case file size @return Parsed file size @throws NumberFormatException Failed to parse file size
[ "Parses", "file", "size", "from", "a", "string", ".", "The", "units", "GB", "MB", "KB", "and", "bytes", "are", "supported", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/policies/SizePolicy.java#L77-L89
train
pmwmedia/tinylog
log4j1.2-api/src/main/java/org/apache/log4j/NDC.java
NDC.push
public static void push(final String message) { InternalLogger.log(org.tinylog.Level.WARN, "tinylog does not support NDC, \"" + message + "\" will be discarded"); }
java
public static void push(final String message) { InternalLogger.log(org.tinylog.Level.WARN, "tinylog does not support NDC, \"" + message + "\" will be discarded"); }
[ "public", "static", "void", "push", "(", "final", "String", "message", ")", "{", "InternalLogger", ".", "log", "(", "org", ".", "tinylog", ".", "Level", ".", "WARN", ",", "\"tinylog does not support NDC, \\\"\"", "+", "message", "+", "\"\\\" will be discarded\"", ...
Push new diagnostic context information for the current thread. <p> The contents of the {@code message} parameter is determined solely by the client. </p> @param message The new diagnostic context information.
[ "Push", "new", "diagnostic", "context", "information", "for", "the", "current", "thread", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/log4j1.2-api/src/main/java/org/apache/log4j/NDC.java#L195-L197
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/core/MessageFormatter.java
MessageFormatter.format
private String format(final String pattern, final Object argument) { try { return getFormatter(pattern, argument).format(argument); } catch (IllegalArgumentException ex) { InternalLogger.log(Level.WARN, "Illegal argument '" + String.valueOf(argument) + "' for pattern '" + pattern + "'"); return String.valu...
java
private String format(final String pattern, final Object argument) { try { return getFormatter(pattern, argument).format(argument); } catch (IllegalArgumentException ex) { InternalLogger.log(Level.WARN, "Illegal argument '" + String.valueOf(argument) + "' for pattern '" + pattern + "'"); return String.valu...
[ "private", "String", "format", "(", "final", "String", "pattern", ",", "final", "Object", "argument", ")", "{", "try", "{", "return", "getFormatter", "(", "pattern", ",", "argument", ")", ".", "format", "(", "argument", ")", ";", "}", "catch", "(", "Ille...
Formats a pattern of a placeholder. @param pattern Pattern of placeholder @param argument Replacement for placeholder @return Formatted pattern
[ "Formats", "a", "pattern", "of", "a", "placeholder", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/core/MessageFormatter.java#L113-L120
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/pattern/SimpleClassNameToken.java
SimpleClassNameToken.getSimpleClassName
private static String getSimpleClassName(final String fullyQualifiedClassName) { int dotIndex = fullyQualifiedClassName.lastIndexOf('.'); if (dotIndex < 0) { return fullyQualifiedClassName; } else { return fullyQualifiedClassName.substring(dotIndex + 1); } }
java
private static String getSimpleClassName(final String fullyQualifiedClassName) { int dotIndex = fullyQualifiedClassName.lastIndexOf('.'); if (dotIndex < 0) { return fullyQualifiedClassName; } else { return fullyQualifiedClassName.substring(dotIndex + 1); } }
[ "private", "static", "String", "getSimpleClassName", "(", "final", "String", "fullyQualifiedClassName", ")", "{", "int", "dotIndex", "=", "fullyQualifiedClassName", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "dotIndex", "<", "0", ")", "{", "return...
Gets the simple class name from a fully qualified class name. @param fullyQualifiedClassName Fully qualified class name @return Class name without package prefix
[ "Gets", "the", "simple", "class", "name", "from", "a", "fully", "qualified", "class", "name", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/pattern/SimpleClassNameToken.java#L59-L66
train
pmwmedia/tinylog
jboss-tinylog/src/main/java/org/tinylog/jboss/TinylogLogger.java
TinylogLogger.translateLevel
private static org.tinylog.Level translateLevel(final Level level) { switch (level) { case TRACE: return org.tinylog.Level.TRACE; case DEBUG: return org.tinylog.Level.DEBUG; case INFO: return org.tinylog.Level.INFO; case WARN: return org.tinylog.Level.WARN; case ERROR: case FATAL: ...
java
private static org.tinylog.Level translateLevel(final Level level) { switch (level) { case TRACE: return org.tinylog.Level.TRACE; case DEBUG: return org.tinylog.Level.DEBUG; case INFO: return org.tinylog.Level.INFO; case WARN: return org.tinylog.Level.WARN; case ERROR: case FATAL: ...
[ "private", "static", "org", ".", "tinylog", ".", "Level", "translateLevel", "(", "final", "Level", "level", ")", "{", "switch", "(", "level", ")", "{", "case", "TRACE", ":", "return", "org", ".", "tinylog", ".", "Level", ".", "TRACE", ";", "case", "DEB...
Translate JBoss Logging severity levels. @param level Severity level from JBoss Logging @return Responding severity level of tinylog
[ "Translate", "JBoss", "Logging", "severity", "levels", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/jboss-tinylog/src/main/java/org/tinylog/jboss/TinylogLogger.java#L1569-L1585
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java
Configuration.getSiblings
public static Map<String, String> getSiblings(final String prefix) { Map<String, String> map = new HashMap<String, String>(); for (Enumeration<Object> enumeration = properties.keys(); enumeration.hasMoreElements();) { String key = (String) enumeration.nextElement(); if (key.startsWith(prefix) && (prefix.endsW...
java
public static Map<String, String> getSiblings(final String prefix) { Map<String, String> map = new HashMap<String, String>(); for (Enumeration<Object> enumeration = properties.keys(); enumeration.hasMoreElements();) { String key = (String) enumeration.nextElement(); if (key.startsWith(prefix) && (prefix.endsW...
[ "public", "static", "Map", "<", "String", ",", "String", ">", "getSiblings", "(", "final", "String", "prefix", ")", "{", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "for", ...
Gets all siblings with a defined prefix. Child properties will be not returned. <p> <strong>Example:</strong> </p> <p> {@code getSiblings("writer")} will return properties with the keys {@code writer} as well as {@code writerTest} but not with the key {@code writer.test}. Dots after a prefix ending with an at sign wi...
[ "Gets", "all", "siblings", "with", "a", "defined", "prefix", ".", "Child", "properties", "will", "be", "not", "returned", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java#L89-L98
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java
Configuration.getChildren
public static Map<String, String> getChildren(final String key) { String prefix = key + "."; Map<String, String> map = new HashMap<String, String>(); for (Enumeration<Object> enumeration = properties.keys(); enumeration.hasMoreElements();) { String property = (String) enumeration.nextElement(); if (propert...
java
public static Map<String, String> getChildren(final String key) { String prefix = key + "."; Map<String, String> map = new HashMap<String, String>(); for (Enumeration<Object> enumeration = properties.keys(); enumeration.hasMoreElements();) { String property = (String) enumeration.nextElement(); if (propert...
[ "public", "static", "Map", "<", "String", ",", "String", ">", "getChildren", "(", "final", "String", "key", ")", "{", "String", "prefix", "=", "key", "+", "\".\"", ";", "Map", "<", "String", ",", "String", ">", "map", "=", "new", "HashMap", "<", "Str...
Gets all child properties for a parent property. The parent property itself will be not returned. Children keys will be returned without parent key prefix. <p> For example: {@code getChildren("writer")} will return the property {@code writer.level} as {@code level}. </p> @param key Case-sensitive key of parent proper...
[ "Gets", "all", "child", "properties", "for", "a", "parent", "property", ".", "The", "parent", "property", "itself", "will", "be", "not", "returned", ".", "Children", "keys", "will", "be", "returned", "without", "parent", "key", "prefix", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java#L112-L123
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java
Configuration.replace
public static void replace(final Map<String, String> configuration) { synchronized (properties) { properties.clear(); properties.putAll(configuration); } }
java
public static void replace(final Map<String, String> configuration) { synchronized (properties) { properties.clear(); properties.putAll(configuration); } }
[ "public", "static", "void", "replace", "(", "final", "Map", "<", "String", ",", "String", ">", "configuration", ")", "{", "synchronized", "(", "properties", ")", "{", "properties", ".", "clear", "(", ")", ";", "properties", ".", "putAll", "(", "configurati...
Replaces the current configuration by a new one. Already existing properties will be dropped. <p> Configuration properties must be set before calling any logging methods. If the framework has been initialized once, the configuration is immutable and further configuration changes will be just ignored. </p> @param conf...
[ "Replaces", "the", "current", "configuration", "by", "a", "new", "one", ".", "Already", "existing", "properties", "will", "be", "dropped", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java#L153-L158
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java
Configuration.load
private static Properties load() { Properties properties = new Properties(); String file = System.getProperty(CONFIGURATION_PROPERTY); try { if (file != null) { InputStream stream; if (URL_DETECTION_PATTERN.matcher(file).matches()) { stream = new URL(file).openStream(); } else { stream =...
java
private static Properties load() { Properties properties = new Properties(); String file = System.getProperty(CONFIGURATION_PROPERTY); try { if (file != null) { InputStream stream; if (URL_DETECTION_PATTERN.matcher(file).matches()) { stream = new URL(file).openStream(); } else { stream =...
[ "private", "static", "Properties", "load", "(", ")", "{", "Properties", "properties", "=", "new", "Properties", "(", ")", ";", "String", "file", "=", "System", ".", "getProperty", "(", "CONFIGURATION_PROPERTY", ")", ";", "try", "{", "if", "(", "file", "!="...
Loads all configuration properties. @return Found properties
[ "Loads", "all", "configuration", "properties", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java#L165-L208
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java
Configuration.load
private static void load(final Properties properties, final InputStream stream) throws IOException { try { properties.load(stream); } finally { stream.close(); } }
java
private static void load(final Properties properties, final InputStream stream) throws IOException { try { properties.load(stream); } finally { stream.close(); } }
[ "private", "static", "void", "load", "(", "final", "Properties", "properties", ",", "final", "InputStream", "stream", ")", "throws", "IOException", "{", "try", "{", "properties", ".", "load", "(", "stream", ")", ";", "}", "finally", "{", "stream", ".", "cl...
Puts all properties from a stream to an existing properties object. Already existing properties will be overridden. @param properties Read properties will be put to this properties object @param stream Input stream with a properties file @throws IOException Failed reading properties from input stream
[ "Puts", "all", "properties", "from", "a", "stream", "to", "an", "existing", "properties", "object", ".", "Already", "existing", "properties", "will", "be", "overridden", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java#L221-L227
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java
Configuration.resolve
private static String resolve(final String value, final Resolver resolver) { StringBuilder builder = new StringBuilder(); int position = 0; String prefix = resolver.getPrefix() + "{"; String postfix = "}"; for (int index = value.indexOf(prefix); index != -1; index = value.indexOf(prefix, position)) { bui...
java
private static String resolve(final String value, final Resolver resolver) { StringBuilder builder = new StringBuilder(); int position = 0; String prefix = resolver.getPrefix() + "{"; String postfix = "}"; for (int index = value.indexOf(prefix); index != -1; index = value.indexOf(prefix, position)) { bui...
[ "private", "static", "String", "resolve", "(", "final", "String", "value", ",", "final", "Resolver", "resolver", ")", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "int", "position", "=", "0", ";", "String", "prefix", "=", "r...
Resolves placeholders with passed resolver. @param value String with placeholders @param resolver Resolver for replacing placeholders @return Input value with resolved placeholders
[ "Resolves", "placeholders", "with", "passed", "resolver", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/configuration/Configuration.java#L238-L275
train
pmwmedia/tinylog
jul-tinylog/src/main/java/org/tinylog/jul/BridgeHandler.java
BridgeHandler.activate
void activate() { LogManager.getLogManager().reset(); Logger logger = Logger.getLogger(""); logger.setLevel(translateLevel(provider.getMinimumLevel(null))); logger.addHandler(this); }
java
void activate() { LogManager.getLogManager().reset(); Logger logger = Logger.getLogger(""); logger.setLevel(translateLevel(provider.getMinimumLevel(null))); logger.addHandler(this); }
[ "void", "activate", "(", ")", "{", "LogManager", ".", "getLogManager", "(", ")", ".", "reset", "(", ")", ";", "Logger", "logger", "=", "Logger", ".", "getLogger", "(", "\"\"", ")", ";", "logger", ".", "setLevel", "(", "translateLevel", "(", "provider", ...
Activates this handler.
[ "Activates", "this", "handler", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/jul-tinylog/src/main/java/org/tinylog/jul/BridgeHandler.java#L59-L65
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/provider/InternalLogger.java
InternalLogger.log
public static void log(final Level level, final String message) { System.err.println("LOGGER " + level + ": " + message); }
java
public static void log(final Level level, final String message) { System.err.println("LOGGER " + level + ": " + message); }
[ "public", "static", "void", "log", "(", "final", "Level", "level", ",", "final", "String", "message", ")", "{", "System", ".", "err", ".", "println", "(", "\"LOGGER \"", "+", "level", "+", "\": \"", "+", "message", ")", ";", "}" ]
Logs a plain text message. @param level Severity level @param message Plain text message
[ "Logs", "a", "plain", "text", "message", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/provider/InternalLogger.java#L37-L39
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/provider/InternalLogger.java
InternalLogger.log
public static void log(final Level level, final Throwable exception) { String nameOfException = exception.getClass().getName(); String messageOfException = exception.getMessage(); if (messageOfException == null || messageOfException.isEmpty()) { System.err.println("LOGGER " + level + ": " + nameOfException); ...
java
public static void log(final Level level, final Throwable exception) { String nameOfException = exception.getClass().getName(); String messageOfException = exception.getMessage(); if (messageOfException == null || messageOfException.isEmpty()) { System.err.println("LOGGER " + level + ": " + nameOfException); ...
[ "public", "static", "void", "log", "(", "final", "Level", "level", ",", "final", "Throwable", "exception", ")", "{", "String", "nameOfException", "=", "exception", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";", "String", "messageOfException", "=",...
Logs a caught exception. @param level Severity level @param exception Caught exception
[ "Logs", "a", "caught", "exception", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/provider/InternalLogger.java#L49-L58
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/provider/InternalLogger.java
InternalLogger.log
public static void log(final Level level, final Throwable exception, final String message) { String nameOfException = exception.getClass().getName(); String messageOfException = exception.getMessage(); StringBuilder builder = new StringBuilder(BUFFER_SIZE); builder.append(level); builder.append(": "); buil...
java
public static void log(final Level level, final Throwable exception, final String message) { String nameOfException = exception.getClass().getName(); String messageOfException = exception.getMessage(); StringBuilder builder = new StringBuilder(BUFFER_SIZE); builder.append(level); builder.append(": "); buil...
[ "public", "static", "void", "log", "(", "final", "Level", "level", ",", "final", "Throwable", "exception", ",", "final", "String", "message", ")", "{", "String", "nameOfException", "=", "exception", ".", "getClass", "(", ")", ".", "getName", "(", ")", ";",...
Logs a caught exception with a custom text message. @param level Severity level @param message Plain text message @param exception Caught exception
[ "Logs", "a", "caught", "exception", "with", "a", "custom", "text", "message", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/provider/InternalLogger.java#L70-L87
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java
JdbcWriter.doWrite
private void doWrite(final LogEntry logEntry) throws SQLException { if (checkConnection()) { if (batch) { batchCount += 1; } try { for (int i = 0; i < tokens.size(); ++i) { tokens.get(i).apply(logEntry, statement, i + 1); } } catch (SQLException ex) { resetConnection(); throw ex;...
java
private void doWrite(final LogEntry logEntry) throws SQLException { if (checkConnection()) { if (batch) { batchCount += 1; } try { for (int i = 0; i < tokens.size(); ++i) { tokens.get(i).apply(logEntry, statement, i + 1); } } catch (SQLException ex) { resetConnection(); throw ex;...
[ "private", "void", "doWrite", "(", "final", "LogEntry", "logEntry", ")", "throws", "SQLException", "{", "if", "(", "checkConnection", "(", ")", ")", "{", "if", "(", "batch", ")", "{", "batchCount", "+=", "1", ";", "}", "try", "{", "for", "(", "int", ...
Unsynchronized method for inserting a log entry. @param logEntry Log entry to insert @throws SQLException Database access failed
[ "Unsynchronized", "method", "for", "inserting", "a", "log", "entry", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java#L141-L173
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java
JdbcWriter.doFlush
private void doFlush() throws SQLException { if (batchCount > 0) { try { statement.executeBatch(); batchCount = 0; } catch (SQLException ex) { resetConnection(); throw ex; } } }
java
private void doFlush() throws SQLException { if (batchCount > 0) { try { statement.executeBatch(); batchCount = 0; } catch (SQLException ex) { resetConnection(); throw ex; } } }
[ "private", "void", "doFlush", "(", ")", "throws", "SQLException", "{", "if", "(", "batchCount", ">", "0", ")", "{", "try", "{", "statement", ".", "executeBatch", "(", ")", ";", "batchCount", "=", "0", ";", "}", "catch", "(", "SQLException", "ex", ")", ...
Unsynchronized method for flushing all cached batch insert statements. @throws SQLException Database access failed
[ "Unsynchronized", "method", "for", "flushing", "all", "cached", "batch", "insert", "statements", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java#L181-L191
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java
JdbcWriter.doClose
private void doClose() throws SQLException { try { if (batch) { doFlush(); } } finally { if (lostCount > 0) { InternalLogger.log(Level.ERROR, "Lost log entries due to broken database connection: " + lostCount); } if (connection != null) { connection.close(); } } }
java
private void doClose() throws SQLException { try { if (batch) { doFlush(); } } finally { if (lostCount > 0) { InternalLogger.log(Level.ERROR, "Lost log entries due to broken database connection: " + lostCount); } if (connection != null) { connection.close(); } } }
[ "private", "void", "doClose", "(", ")", "throws", "SQLException", "{", "try", "{", "if", "(", "batch", ")", "{", "doFlush", "(", ")", ";", "}", "}", "finally", "{", "if", "(", "lostCount", ">", "0", ")", "{", "InternalLogger", ".", "log", "(", "Lev...
Unsynchronized method for closing database connection. @throws SQLException Database access failed
[ "Unsynchronized", "method", "for", "closing", "database", "connection", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java#L199-L213
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java
JdbcWriter.checkConnection
private boolean checkConnection() { if (connection == null) { if (System.currentTimeMillis() >= reconnectTimestamp) { long start = System.currentTimeMillis(); try { connection = connect(url, user, password); statement = connection.prepareStatement(sql); InternalLogger.log(Level.ERROR, "Lost ...
java
private boolean checkConnection() { if (connection == null) { if (System.currentTimeMillis() >= reconnectTimestamp) { long start = System.currentTimeMillis(); try { connection = connect(url, user, password); statement = connection.prepareStatement(sql); InternalLogger.log(Level.ERROR, "Lost ...
[ "private", "boolean", "checkConnection", "(", ")", "{", "if", "(", "connection", "==", "null", ")", "{", "if", "(", "System", ".", "currentTimeMillis", "(", ")", ">=", "reconnectTimestamp", ")", "{", "long", "start", "=", "System", ".", "currentTimeMillis", ...
Checks if database connection is opened. Regular attempts are made to reestablish a broken database connection. @return {@code true} if database connection is opened, otherwise {@code false}
[ "Checks", "if", "database", "connection", "is", "opened", ".", "Regular", "attempts", "are", "made", "to", "reestablish", "a", "broken", "database", "connection", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java#L220-L247
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java
JdbcWriter.resetConnection
private void resetConnection() { if (reconnect) { closeConnectionSilently(); statement = null; lostCount = batch ? batchCount : 1; batchCount = 0; reconnectTimestamp = 0; } }
java
private void resetConnection() { if (reconnect) { closeConnectionSilently(); statement = null; lostCount = batch ? batchCount : 1; batchCount = 0; reconnectTimestamp = 0; } }
[ "private", "void", "resetConnection", "(", ")", "{", "if", "(", "reconnect", ")", "{", "closeConnectionSilently", "(", ")", ";", "statement", "=", "null", ";", "lostCount", "=", "batch", "?", "batchCount", ":", "1", ";", "batchCount", "=", "0", ";", "rec...
Resets the database connection after an error, if automatic reconnection is enabled.
[ "Resets", "the", "database", "connection", "after", "an", "error", "if", "automatic", "reconnection", "is", "enabled", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java#L252-L260
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java
JdbcWriter.connect
private static Connection connect(final String url, final String user, final String password) throws NamingException, SQLException { if (url.toLowerCase(Locale.ROOT).startsWith("java:")) { DataSource source = (DataSource) new InitialContext().lookup(url); if (user == null) { return source.getConnection(); ...
java
private static Connection connect(final String url, final String user, final String password) throws NamingException, SQLException { if (url.toLowerCase(Locale.ROOT).startsWith("java:")) { DataSource source = (DataSource) new InitialContext().lookup(url); if (user == null) { return source.getConnection(); ...
[ "private", "static", "Connection", "connect", "(", "final", "String", "url", ",", "final", "String", "user", ",", "final", "String", "password", ")", "throws", "NamingException", ",", "SQLException", "{", "if", "(", "url", ".", "toLowerCase", "(", "Locale", ...
Establishes the connection to the database. @param url JDBC or data source URL @param user User name for login (can be {@code null} if no login is required) @param password Password for login (can be {@code null} if no login is required) @return Connection to the database @throws NamingException Requested data source...
[ "Establishes", "the", "connection", "to", "the", "database", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java#L295-L310
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java
JdbcWriter.getUrl
private static String getUrl(final Map<String, String> properties) { String url = properties.get("url"); if (url == null) { throw new IllegalArgumentException("URL is missing for JDBC writer"); } else { return url; } }
java
private static String getUrl(final Map<String, String> properties) { String url = properties.get("url"); if (url == null) { throw new IllegalArgumentException("URL is missing for JDBC writer"); } else { return url; } }
[ "private", "static", "String", "getUrl", "(", "final", "Map", "<", "String", ",", "String", ">", "properties", ")", "{", "String", "url", "=", "properties", ".", "get", "(", "\"url\"", ")", ";", "if", "(", "url", "==", "null", ")", "{", "throw", "new...
Extracts the URL to database or data source from configuration. @param properties Configuration for writer @return Connection URL @throws IllegalArgumentException URL is not defined in configuration
[ "Extracts", "the", "URL", "to", "database", "or", "data", "source", "from", "configuration", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java#L322-L329
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java
JdbcWriter.getTable
private static String getTable(final Map<String, String> properties) { String table = properties.get("table"); if (table == null) { throw new IllegalArgumentException("Name of database table is missing for JDBC writer"); } else { return table; } }
java
private static String getTable(final Map<String, String> properties) { String table = properties.get("table"); if (table == null) { throw new IllegalArgumentException("Name of database table is missing for JDBC writer"); } else { return table; } }
[ "private", "static", "String", "getTable", "(", "final", "Map", "<", "String", ",", "String", ">", "properties", ")", "{", "String", "table", "=", "properties", ".", "get", "(", "\"table\"", ")", ";", "if", "(", "table", "==", "null", ")", "{", "throw"...
Extracts the database table name from configuration. @param properties Configuration for writer @return Name of database table @throws IllegalArgumentException Table is not defined in configuration
[ "Extracts", "the", "database", "table", "name", "from", "configuration", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java#L341-L348
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java
JdbcWriter.renderSql
private static String renderSql(final Map<String, String> properties, final String quote) throws SQLException { StringBuilder builder = new StringBuilder(); builder.append("INSERT INTO "); append(builder, getTable(properties), quote); builder.append(" ("); int count = 0; for (Entry<String, String> entry :...
java
private static String renderSql(final Map<String, String> properties, final String quote) throws SQLException { StringBuilder builder = new StringBuilder(); builder.append("INSERT INTO "); append(builder, getTable(properties), quote); builder.append(" ("); int count = 0; for (Entry<String, String> entry :...
[ "private", "static", "String", "renderSql", "(", "final", "Map", "<", "String", ",", "String", ">", "properties", ",", "final", "String", "quote", ")", "throws", "SQLException", "{", "StringBuilder", "builder", "=", "new", "StringBuilder", "(", ")", ";", "bu...
Generates an insert SQL statement for the configured table and its fields. @param properties Properties that contains the configured table and fields @param quote Character for quoting identifiers (can be a space if the database doesn't support quote characters) @return SQL statement for {@link PreparedStatement} @th...
[ "Generates", "an", "insert", "SQL", "statement", "for", "the", "configured", "table", "and", "its", "fields", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java#L362-L396
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java
JdbcWriter.append
private static void append(final StringBuilder builder, final String identifier, final String quote) throws SQLException { if (identifier.indexOf('\n') >= 0 || identifier.indexOf('\r') >= 0) { throw new SQLException("Identifier contains line breaks: " + identifier); } else if (" ".equals(quote)) { for (int i ...
java
private static void append(final StringBuilder builder, final String identifier, final String quote) throws SQLException { if (identifier.indexOf('\n') >= 0 || identifier.indexOf('\r') >= 0) { throw new SQLException("Identifier contains line breaks: " + identifier); } else if (" ".equals(quote)) { for (int i ...
[ "private", "static", "void", "append", "(", "final", "StringBuilder", "builder", ",", "final", "String", "identifier", ",", "final", "String", "quote", ")", "throws", "SQLException", "{", "if", "(", "identifier", ".", "indexOf", "(", "'", "'", ")", ">=", "...
Appends a database identifier securely to a builder that is building a SQL statement. @param builder String builder that is building a SQL statement @param identifier Identifier to add @param quote Character for quoting the identifier (can be a space if the database doesn't support quote characters) @throws SQLExcept...
[ "Appends", "a", "database", "identifier", "securely", "to", "a", "builder", "that", "is", "building", "a", "SQL", "statement", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java#L411-L425
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java
JdbcWriter.createTokens
private static List<Token> createTokens(final Map<String, String> properties) { List<Token> tokens = new ArrayList<Token>(); for (Entry<String, String> entry : properties.entrySet()) { if (entry.getKey().toLowerCase(Locale.ROOT).startsWith(FIELD_PREFIX)) { tokens.add(FormatPatternParser.parse(entry.getValue(...
java
private static List<Token> createTokens(final Map<String, String> properties) { List<Token> tokens = new ArrayList<Token>(); for (Entry<String, String> entry : properties.entrySet()) { if (entry.getKey().toLowerCase(Locale.ROOT).startsWith(FIELD_PREFIX)) { tokens.add(FormatPatternParser.parse(entry.getValue(...
[ "private", "static", "List", "<", "Token", ">", "createTokens", "(", "final", "Map", "<", "String", ",", "String", ">", "properties", ")", "{", "List", "<", "Token", ">", "tokens", "=", "new", "ArrayList", "<", "Token", ">", "(", ")", ";", "for", "("...
Creates tokens for all configured fields. @param properties Properties that contains the configured fields @return Tokens for filling a {@link PreparedStatement}
[ "Creates", "tokens", "for", "all", "configured", "fields", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/writers/JdbcWriter.java#L434-L442
train
pmwmedia/tinylog
log4j1.2-api/src/main/java/org/apache/log4j/Category.java
Category.isCoveredByMinimumLevel
protected static boolean isCoveredByMinimumLevel(final org.tinylog.Level level) { return provider.getMinimumLevel(null).ordinal() <= level.ordinal(); }
java
protected static boolean isCoveredByMinimumLevel(final org.tinylog.Level level) { return provider.getMinimumLevel(null).ordinal() <= level.ordinal(); }
[ "protected", "static", "boolean", "isCoveredByMinimumLevel", "(", "final", "org", ".", "tinylog", ".", "Level", "level", ")", "{", "return", "provider", ".", "getMinimumLevel", "(", "null", ")", ".", "ordinal", "(", ")", "<=", "level", ".", "ordinal", "(", ...
Checks if a given severity level is covered by the logging provider's minimum level. @param level Severity level to check @return {@code true} if given severity level is covered, otherwise {@code false}
[ "Checks", "if", "a", "given", "severity", "level", "is", "covered", "by", "the", "logging", "provider", "s", "minimum", "level", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/log4j1.2-api/src/main/java/org/apache/log4j/Category.java#L869-L871
train
pmwmedia/tinylog
log4j1.2-api/src/main/java/org/apache/log4j/Category.java
Category.translatePriority
private static org.tinylog.Level translatePriority(final Priority priority) { if (priority.isGreaterOrEqual(Level.ERROR)) { return org.tinylog.Level.ERROR; } else if (priority.isGreaterOrEqual(Level.WARN)) { return org.tinylog.Level.WARN; } else if (priority.isGreaterOrEqual(Level.INFO)) { return org.tin...
java
private static org.tinylog.Level translatePriority(final Priority priority) { if (priority.isGreaterOrEqual(Level.ERROR)) { return org.tinylog.Level.ERROR; } else if (priority.isGreaterOrEqual(Level.WARN)) { return org.tinylog.Level.WARN; } else if (priority.isGreaterOrEqual(Level.INFO)) { return org.tin...
[ "private", "static", "org", ".", "tinylog", ".", "Level", "translatePriority", "(", "final", "Priority", "priority", ")", "{", "if", "(", "priority", ".", "isGreaterOrEqual", "(", "Level", ".", "ERROR", ")", ")", "{", "return", "org", ".", "tinylog", ".", ...
Translates an Apache Log4j 1.2 priority into a tinylog 2 severity level. @param priority Apache Log4j 1.2 priority @return Corresponding severity level of tinylog 2
[ "Translates", "an", "Apache", "Log4j", "1", ".", "2", "priority", "into", "a", "tinylog", "2", "severity", "level", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/log4j1.2-api/src/main/java/org/apache/log4j/Category.java#L880-L892
train
pmwmedia/tinylog
log4j1.2-api/src/main/java/org/apache/log4j/Category.java
Category.translateLevel
private static Level translateLevel(final org.tinylog.Level level) { switch (level) { case TRACE: return Level.TRACE; case DEBUG: return Level.DEBUG; case INFO: return Level.INFO; case WARN: return Level.WARN; case ERROR: return Level.ERROR; case OFF: return Level.OFF; def...
java
private static Level translateLevel(final org.tinylog.Level level) { switch (level) { case TRACE: return Level.TRACE; case DEBUG: return Level.DEBUG; case INFO: return Level.INFO; case WARN: return Level.WARN; case ERROR: return Level.ERROR; case OFF: return Level.OFF; def...
[ "private", "static", "Level", "translateLevel", "(", "final", "org", ".", "tinylog", ".", "Level", "level", ")", "{", "switch", "(", "level", ")", "{", "case", "TRACE", ":", "return", "Level", ".", "TRACE", ";", "case", "DEBUG", ":", "return", "Level", ...
Translates a tinylog 2 severity level into an Apache Log4j 1.2 level. @param level Severity level of tinylog 2 @return Corresponding level of Apache Log4j 1.2
[ "Translates", "a", "tinylog", "2", "severity", "level", "into", "an", "Apache", "Log4j", "1", ".", "2", "level", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/log4j1.2-api/src/main/java/org/apache/log4j/Category.java#L901-L918
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/provider/BundleLoggingProvider.java
BundleLoggingProvider.createContextProvider
private static ContextProvider createContextProvider(final Collection<LoggingProvider> loggingProviders) { Collection<ContextProvider> contextProviders = new ArrayList<ContextProvider>(loggingProviders.size()); for (LoggingProvider loggingProvider : loggingProviders) { contextProviders.add(loggingProvider.getCon...
java
private static ContextProvider createContextProvider(final Collection<LoggingProvider> loggingProviders) { Collection<ContextProvider> contextProviders = new ArrayList<ContextProvider>(loggingProviders.size()); for (LoggingProvider loggingProvider : loggingProviders) { contextProviders.add(loggingProvider.getCon...
[ "private", "static", "ContextProvider", "createContextProvider", "(", "final", "Collection", "<", "LoggingProvider", ">", "loggingProviders", ")", "{", "Collection", "<", "ContextProvider", ">", "contextProviders", "=", "new", "ArrayList", "<", "ContextProvider", ">", ...
Gets all context providers from given logging providers and combine them into a new one. @param loggingProviders Context providers of these logging providers will be fetched @return All context providers combined into a new one
[ "Gets", "all", "context", "providers", "from", "given", "logging", "providers", "and", "combine", "them", "into", "a", "new", "one", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/provider/BundleLoggingProvider.java#L108-L114
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/pattern/FormatPatternParser.java
FormatPatternParser.parse
public static Token parse(final String pattern) { List<Token> tokens = new ArrayList<Token>(); int start = 0; int count = 0; for (int i = 0; i < pattern.length(); ++i) { char character = pattern.charAt(i); if (character == '{') { if (count == 0) { if (start < i) { tokens.add(new PlainTex...
java
public static Token parse(final String pattern) { List<Token> tokens = new ArrayList<Token>(); int start = 0; int count = 0; for (int i = 0; i < pattern.length(); ++i) { char character = pattern.charAt(i); if (character == '{') { if (count == 0) { if (start < i) { tokens.add(new PlainTex...
[ "public", "static", "Token", "parse", "(", "final", "String", "pattern", ")", "{", "List", "<", "Token", ">", "tokens", "=", "new", "ArrayList", "<", "Token", ">", "(", ")", ";", "int", "start", "=", "0", ";", "int", "count", "=", "0", ";", "for", ...
Parses a format pattern and produces a generic token from it. This token can be used by writers for rendering log entries. @param pattern Format pattern @return Produced root token
[ "Parses", "a", "format", "pattern", "and", "produces", "a", "generic", "token", "from", "it", ".", "This", "token", "can", "be", "used", "by", "writers", "for", "rendering", "log", "entries", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/pattern/FormatPatternParser.java#L43-L87
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/pattern/FormatPatternParser.java
FormatPatternParser.createPlainToken
private static Token createPlainToken(final String placeholder) { int splitIndex = placeholder.indexOf(':'); Token token; if (splitIndex == -1) { token = createPlainToken(placeholder.trim(), null); } else { String name = placeholder.substring(0, splitIndex).trim(); String configuration = placeholder.s...
java
private static Token createPlainToken(final String placeholder) { int splitIndex = placeholder.indexOf(':'); Token token; if (splitIndex == -1) { token = createPlainToken(placeholder.trim(), null); } else { String name = placeholder.substring(0, splitIndex).trim(); String configuration = placeholder.s...
[ "private", "static", "Token", "createPlainToken", "(", "final", "String", "placeholder", ")", "{", "int", "splitIndex", "=", "placeholder", ".", "indexOf", "(", "'", "'", ")", ";", "Token", "token", ";", "if", "(", "splitIndex", "==", "-", "1", ")", "{",...
Creates a new token for a given placeholder. @param placeholder Placeholder without style options and surrounding curly brackets @return Created token
[ "Creates", "a", "new", "token", "for", "a", "given", "placeholder", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/pattern/FormatPatternParser.java#L96-L109
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/pattern/FormatPatternParser.java
FormatPatternParser.createPlainToken
private static Token createPlainToken(final String name, final String configuration) { if (name.equals("date")) { return createDateToken(configuration); } else if ("pid".equals(name)) { return new ProcessIdToken(); } else if ("thread".equals(name)) { return new ThreadNameToken(); } else if ("thread-id"...
java
private static Token createPlainToken(final String name, final String configuration) { if (name.equals("date")) { return createDateToken(configuration); } else if ("pid".equals(name)) { return new ProcessIdToken(); } else if ("thread".equals(name)) { return new ThreadNameToken(); } else if ("thread-id"...
[ "private", "static", "Token", "createPlainToken", "(", "final", "String", "name", ",", "final", "String", "configuration", ")", "{", "if", "(", "name", ".", "equals", "(", "\"date\"", ")", ")", "{", "return", "createDateToken", "(", "configuration", ")", ";"...
Creates a new token for a name and configuration. @param name Name of token @param configuration Configuration for token or {@code null} if not defined @return Created token or {@code null} if there is no token for the passed parameters
[ "Creates", "a", "new", "token", "for", "a", "name", "and", "configuration", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/pattern/FormatPatternParser.java#L120-L162
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/pattern/FormatPatternParser.java
FormatPatternParser.styleToken
private static Token styleToken(final Token token, final String[] options) { Token styledToken = token; for (String option : options) { int splitIndex = option.indexOf('='); if (splitIndex == -1) { InternalLogger.log(Level.ERROR, "No value set for '" + option.trim() + "'"); } else { String key = o...
java
private static Token styleToken(final Token token, final String[] options) { Token styledToken = token; for (String option : options) { int splitIndex = option.indexOf('='); if (splitIndex == -1) { InternalLogger.log(Level.ERROR, "No value set for '" + option.trim() + "'"); } else { String key = o...
[ "private", "static", "Token", "styleToken", "(", "final", "Token", "token", ",", "final", "String", "[", "]", "options", ")", "{", "Token", "styledToken", "=", "token", ";", "for", "(", "String", "option", ":", "options", ")", "{", "int", "splitIndex", "...
Creates style decorators for a token. @param token Token to style @param options Style options @return Styled token
[ "Creates", "style", "decorators", "for", "a", "token", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/pattern/FormatPatternParser.java#L217-L247
train
pmwmedia/tinylog
tinylog-api/src/main/java/org/tinylog/provider/ProviderRegistry.java
ProviderRegistry.loadLoggingProvider
private static LoggingProvider loadLoggingProvider() { ServiceLoader<LoggingProvider> loader = new ServiceLoader<LoggingProvider>(LoggingProvider.class); String name = Configuration.get(PROVIDER_PROPERTY); if (name == null) { Collection<LoggingProvider> providers = loader.createAll(); switch (providers.siz...
java
private static LoggingProvider loadLoggingProvider() { ServiceLoader<LoggingProvider> loader = new ServiceLoader<LoggingProvider>(LoggingProvider.class); String name = Configuration.get(PROVIDER_PROPERTY); if (name == null) { Collection<LoggingProvider> providers = loader.createAll(); switch (providers.siz...
[ "private", "static", "LoggingProvider", "loadLoggingProvider", "(", ")", "{", "ServiceLoader", "<", "LoggingProvider", ">", "loader", "=", "new", "ServiceLoader", "<", "LoggingProvider", ">", "(", "LoggingProvider", ".", "class", ")", ";", "String", "name", "=", ...
Loads the actual logging provider. @return New logging provider instance
[ "Loads", "the", "actual", "logging", "provider", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-api/src/main/java/org/tinylog/provider/ProviderRegistry.java#L60-L87
train
pmwmedia/tinylog
benchmarks/src/main/java/org/tinylog/benchmarks/api/StackTraceBenchmark.java
StackTraceBenchmark.stackWalkerWithLambda
@Benchmark @BenchmarkMode(Mode.Throughput) public StackFrame stackWalkerWithLambda() { return StackWalker.getInstance().walk(stream -> stream.skip(1).findFirst().get()); }
java
@Benchmark @BenchmarkMode(Mode.Throughput) public StackFrame stackWalkerWithLambda() { return StackWalker.getInstance().walk(stream -> stream.skip(1).findFirst().get()); }
[ "@", "Benchmark", "@", "BenchmarkMode", "(", "Mode", ".", "Throughput", ")", "public", "StackFrame", "stackWalkerWithLambda", "(", ")", "{", "return", "StackWalker", ".", "getInstance", "(", ")", ".", "walk", "(", "stream", "->", "stream", ".", "skip", "(", ...
Benchmarks extracting a stack frame from stack walker by using a lambda expression. @return Found stack frame
[ "Benchmarks", "extracting", "a", "stack", "frame", "from", "stack", "walker", "by", "using", "a", "lambda", "expression", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/benchmarks/src/main/java/org/tinylog/benchmarks/api/StackTraceBenchmark.java#L42-L46
train
pmwmedia/tinylog
benchmarks/src/main/java/org/tinylog/benchmarks/api/StackTraceBenchmark.java
StackTraceBenchmark.stackWalkerWithAnonymousClass
@Benchmark @BenchmarkMode(Mode.Throughput) public StackFrame stackWalkerWithAnonymousClass() { return StackWalker.getInstance().walk(new Function<Stream<StackFrame>, StackFrame>() { @Override public StackFrame apply(final Stream<StackFrame> stream) { return stream.skip(1).findFirst().get(); } }); }
java
@Benchmark @BenchmarkMode(Mode.Throughput) public StackFrame stackWalkerWithAnonymousClass() { return StackWalker.getInstance().walk(new Function<Stream<StackFrame>, StackFrame>() { @Override public StackFrame apply(final Stream<StackFrame> stream) { return stream.skip(1).findFirst().get(); } }); }
[ "@", "Benchmark", "@", "BenchmarkMode", "(", "Mode", ".", "Throughput", ")", "public", "StackFrame", "stackWalkerWithAnonymousClass", "(", ")", "{", "return", "StackWalker", ".", "getInstance", "(", ")", ".", "walk", "(", "new", "Function", "<", "Stream", "<",...
Benchmarks extracting a stack frame from stack walker by using an anonymous inner class. @return Found stack frame
[ "Benchmarks", "extracting", "a", "stack", "frame", "from", "stack", "walker", "by", "using", "an", "anonymous", "inner", "class", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/benchmarks/src/main/java/org/tinylog/benchmarks/api/StackTraceBenchmark.java#L53-L62
train
pmwmedia/tinylog
benchmarks/src/main/java/org/tinylog/benchmarks/api/StackTraceBenchmark.java
StackTraceBenchmark.stackWalkerWithInnerClass
@Benchmark @BenchmarkMode(Mode.Throughput) public StackFrame stackWalkerWithInnerClass() { return StackWalker.getInstance().walk(new StackFrameExtractor(1)); }
java
@Benchmark @BenchmarkMode(Mode.Throughput) public StackFrame stackWalkerWithInnerClass() { return StackWalker.getInstance().walk(new StackFrameExtractor(1)); }
[ "@", "Benchmark", "@", "BenchmarkMode", "(", "Mode", ".", "Throughput", ")", "public", "StackFrame", "stackWalkerWithInnerClass", "(", ")", "{", "return", "StackWalker", ".", "getInstance", "(", ")", ".", "walk", "(", "new", "StackFrameExtractor", "(", "1", ")...
Benchmarks extracting a stack frame from stack walker by using a static inner class. @return Found stack frame
[ "Benchmarks", "extracting", "a", "stack", "frame", "from", "stack", "walker", "by", "using", "a", "static", "inner", "class", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/benchmarks/src/main/java/org/tinylog/benchmarks/api/StackTraceBenchmark.java#L69-L73
train
pmwmedia/tinylog
benchmarks/src/main/java/org/tinylog/benchmarks/api/StackTraceBenchmark.java
StackTraceBenchmark.sunReflection
@Benchmark @BenchmarkMode(Mode.Throughput) @SuppressWarnings("removal") public Class<?> sunReflection() { return sun.reflect.Reflection.getCallerClass(1); }
java
@Benchmark @BenchmarkMode(Mode.Throughput) @SuppressWarnings("removal") public Class<?> sunReflection() { return sun.reflect.Reflection.getCallerClass(1); }
[ "@", "Benchmark", "@", "BenchmarkMode", "(", "Mode", ".", "Throughput", ")", "@", "SuppressWarnings", "(", "\"removal\"", ")", "public", "Class", "<", "?", ">", "sunReflection", "(", ")", "{", "return", "sun", ".", "reflect", ".", "Reflection", ".", "getCa...
Benchmarks extracting a class via Sun reflection. @return Found class
[ "Benchmarks", "extracting", "a", "class", "via", "Sun", "reflection", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/benchmarks/src/main/java/org/tinylog/benchmarks/api/StackTraceBenchmark.java#L80-L85
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/pattern/PackageNameToken.java
PackageNameToken.getPackage
private static String getPackage(final String fullyQualifiedClassName) { int dotIndex = fullyQualifiedClassName.lastIndexOf('.'); if (dotIndex == -1) { return null; } else { return fullyQualifiedClassName.substring(0, dotIndex); } }
java
private static String getPackage(final String fullyQualifiedClassName) { int dotIndex = fullyQualifiedClassName.lastIndexOf('.'); if (dotIndex == -1) { return null; } else { return fullyQualifiedClassName.substring(0, dotIndex); } }
[ "private", "static", "String", "getPackage", "(", "final", "String", "fullyQualifiedClassName", ")", "{", "int", "dotIndex", "=", "fullyQualifiedClassName", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "dotIndex", "==", "-", "1", ")", "{", "return...
Gets the package name from a fully qualified class name. @param fullyQualifiedClassName Fully qualified class name @return Package name or {@code null} for default package
[ "Gets", "the", "package", "name", "from", "a", "fully", "qualified", "class", "name", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/pattern/PackageNameToken.java#L58-L65
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/path/CountSegment.java
CountSegment.parseDigits
private static Long parseDigits(final String text, final int start) { for (int i = start; i < text.length(); ++i) { char character = text.charAt(i); if (character < '0' || character > '9') { return parseLong(text.substring(start, i)); } } return parseLong(text.substring(start)); }
java
private static Long parseDigits(final String text, final int start) { for (int i = start; i < text.length(); ++i) { char character = text.charAt(i); if (character < '0' || character > '9') { return parseLong(text.substring(start, i)); } } return parseLong(text.substring(start)); }
[ "private", "static", "Long", "parseDigits", "(", "final", "String", "text", ",", "final", "int", "start", ")", "{", "for", "(", "int", "i", "=", "start", ";", "i", "<", "text", ".", "length", "(", ")", ";", "++", "i", ")", "{", "char", "character",...
Parses digits from a defined position in a text. Following non-numeric characters will be ignored. @param text Text that potentially contains digits @param start Position in text from which digits should be parsed @return Parsed digits or {@code null} if there is no valid number at the defined position
[ "Parses", "digits", "from", "a", "defined", "position", "in", "a", "text", ".", "Following", "non", "-", "numeric", "characters", "will", "be", "ignored", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/path/CountSegment.java#L87-L96
train
pmwmedia/tinylog
tinylog-impl/src/main/java/org/tinylog/path/CountSegment.java
CountSegment.parseLong
private static Long parseLong(final String text) { if (text.length() == 0) { return null; } else { try { return Long.parseLong(text); } catch (NumberFormatException ex) { return null; } } }
java
private static Long parseLong(final String text) { if (text.length() == 0) { return null; } else { try { return Long.parseLong(text); } catch (NumberFormatException ex) { return null; } } }
[ "private", "static", "Long", "parseLong", "(", "final", "String", "text", ")", "{", "if", "(", "text", ".", "length", "(", ")", "==", "0", ")", "{", "return", "null", ";", "}", "else", "{", "try", "{", "return", "Long", ".", "parseLong", "(", "text...
Converts a text into a number. @param text Text that potentially represents a number @return Parsed number or {@code null} if the passed text cannot be parsed as a number
[ "Converts", "a", "text", "into", "a", "number", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/tinylog-impl/src/main/java/org/tinylog/path/CountSegment.java#L105-L115
train
pmwmedia/tinylog
slf4j-tinylog/src/main/java/org/tinylog/slf4j/TinylogLogger.java
TinylogLogger.translateLevel
private static Level translateLevel(final int level) { if (level <= TRACE_INT) { return Level.TRACE; } else if (level <= DEBUG_INT) { return Level.DEBUG; } else if (level <= INFO_INT) { return Level.INFO; } else if (level <= WARN_INT) { return Level.WARN; } else { return Level.ERROR; } }
java
private static Level translateLevel(final int level) { if (level <= TRACE_INT) { return Level.TRACE; } else if (level <= DEBUG_INT) { return Level.DEBUG; } else if (level <= INFO_INT) { return Level.INFO; } else if (level <= WARN_INT) { return Level.WARN; } else { return Level.ERROR; } }
[ "private", "static", "Level", "translateLevel", "(", "final", "int", "level", ")", "{", "if", "(", "level", "<=", "TRACE_INT", ")", "{", "return", "Level", ".", "TRACE", ";", "}", "else", "if", "(", "level", "<=", "DEBUG_INT", ")", "{", "return", "Leve...
Translate SLF4J severity level codes. @param level Severity level code from SLF4J @return Responding severity level of tinylog
[ "Translate", "SLF4J", "severity", "level", "codes", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/slf4j-tinylog/src/main/java/org/tinylog/slf4j/TinylogLogger.java#L501-L513
train
pmwmedia/tinylog
slf4j-tinylog/src/main/java/org/tinylog/slf4j/TinylogLogger.java
TinylogLogger.extractThrowable
private static Throwable extractThrowable(final Object[] arguments) { return arguments.length == 0 ? null : extractThrowable(arguments[arguments.length - 1]); }
java
private static Throwable extractThrowable(final Object[] arguments) { return arguments.length == 0 ? null : extractThrowable(arguments[arguments.length - 1]); }
[ "private", "static", "Throwable", "extractThrowable", "(", "final", "Object", "[", "]", "arguments", ")", "{", "return", "arguments", ".", "length", "==", "0", "?", "null", ":", "extractThrowable", "(", "arguments", "[", "arguments", ".", "length", "-", "1",...
Returns a throwable if the last argument is one. @param arguments Passed arguments @return Last argument as throwable or {@code null}
[ "Returns", "a", "throwable", "if", "the", "last", "argument", "is", "one", "." ]
d03d4ef84a1310155037e08ca8822a91697d1086
https://github.com/pmwmedia/tinylog/blob/d03d4ef84a1310155037e08ca8822a91697d1086/slf4j-tinylog/src/main/java/org/tinylog/slf4j/TinylogLogger.java#L522-L524
train
TGIO/RNCryptorNative
jncryptor/src/main/java/org/cryptonode/jncryptor/AES256Ciphertext.java
AES256Ciphertext.validateLength
private static void validateLength(byte[] data, String dataName, int expectedLength) throws IllegalArgumentException { if (data.length != expectedLength) { throw new IllegalArgumentException(String.format( "Invalid %s length. Expected %d bytes but found %d.", dataName, expectedLength...
java
private static void validateLength(byte[] data, String dataName, int expectedLength) throws IllegalArgumentException { if (data.length != expectedLength) { throw new IllegalArgumentException(String.format( "Invalid %s length. Expected %d bytes but found %d.", dataName, expectedLength...
[ "private", "static", "void", "validateLength", "(", "byte", "[", "]", "data", ",", "String", "dataName", ",", "int", "expectedLength", ")", "throws", "IllegalArgumentException", "{", "if", "(", "data", ".", "length", "!=", "expectedLength", ")", "{", "throw", ...
Checks the length of a byte array. @param data the data to check @param dataName the name of the field (to include in the exception) @param expectedLength the length the data should be @throws IllegalArgumentException if the data is not of the correct length
[ "Checks", "the", "length", "of", "a", "byte", "array", "." ]
5209f10b988e4033c0b769a40b0d6cc99ea16af7
https://github.com/TGIO/RNCryptorNative/blob/5209f10b988e4033c0b769a40b0d6cc99ea16af7/jncryptor/src/main/java/org/cryptonode/jncryptor/AES256Ciphertext.java#L198-L205
train
TGIO/RNCryptorNative
jncryptor/src/main/java/org/cryptonode/jncryptor/AES256Ciphertext.java
AES256Ciphertext.getRawData
byte[] getRawData() { // Header: [Version | Options] byte[] header = new byte[] { (byte) getVersionNumber(), 0 }; if (isPasswordBased) { header[1] |= FLAG_PASSWORD; } // Pack result final int dataSize; if (isPasswordBased) { dataSize = header.length + encryptionSalt.length + ...
java
byte[] getRawData() { // Header: [Version | Options] byte[] header = new byte[] { (byte) getVersionNumber(), 0 }; if (isPasswordBased) { header[1] |= FLAG_PASSWORD; } // Pack result final int dataSize; if (isPasswordBased) { dataSize = header.length + encryptionSalt.length + ...
[ "byte", "[", "]", "getRawData", "(", ")", "{", "// Header: [Version | Options]", "byte", "[", "]", "header", "=", "new", "byte", "[", "]", "{", "(", "byte", ")", "getVersionNumber", "(", ")", ",", "0", "}", ";", "if", "(", "isPasswordBased", ")", "{", ...
Returns the ciphertext, packaged as a byte array. @return the byte array
[ "Returns", "the", "ciphertext", "packaged", "as", "a", "byte", "array", "." ]
5209f10b988e4033c0b769a40b0d6cc99ea16af7
https://github.com/TGIO/RNCryptorNative/blob/5209f10b988e4033c0b769a40b0d6cc99ea16af7/jncryptor/src/main/java/org/cryptonode/jncryptor/AES256Ciphertext.java#L212-L256
train
TGIO/RNCryptorNative
jncryptor/src/main/java/org/cryptonode/jncryptor/Validate.java
Validate.isCorrectLength
static void isCorrectLength(byte[] object, int length, String name) { Validate.notNull(object, "%s cannot be null.", name); Validate.isTrue(object.length == length, "%s should be %d bytes, found %d bytes.", name, length, object.length); }
java
static void isCorrectLength(byte[] object, int length, String name) { Validate.notNull(object, "%s cannot be null.", name); Validate.isTrue(object.length == length, "%s should be %d bytes, found %d bytes.", name, length, object.length); }
[ "static", "void", "isCorrectLength", "(", "byte", "[", "]", "object", ",", "int", "length", ",", "String", "name", ")", "{", "Validate", ".", "notNull", "(", "object", ",", "\"%s cannot be null.\"", ",", "name", ")", ";", "Validate", ".", "isTrue", "(", ...
Tests object is not null and is of correct length. @param object @param length @param name
[ "Tests", "object", "is", "not", "null", "and", "is", "of", "correct", "length", "." ]
5209f10b988e4033c0b769a40b0d6cc99ea16af7
https://github.com/TGIO/RNCryptorNative/blob/5209f10b988e4033c0b769a40b0d6cc99ea16af7/jncryptor/src/main/java/org/cryptonode/jncryptor/Validate.java#L44-L49
train
TGIO/RNCryptorNative
jncryptor/src/main/java/org/cryptonode/jncryptor/AES256JNCryptorOutputStream.java
AES256JNCryptorOutputStream.createStreams
private void createStreams(SecretKey encryptionKey, SecretKey hmacKey, byte[] iv, OutputStream out) throws CryptorException { this.iv = iv; try { Cipher cipher = Cipher.getInstance(AES256JNCryptor.AES_CIPHER_ALGORITHM); cipher.init(Cipher.ENCRYPT_MODE, encryptionKey, new IvParameterSpec(iv))...
java
private void createStreams(SecretKey encryptionKey, SecretKey hmacKey, byte[] iv, OutputStream out) throws CryptorException { this.iv = iv; try { Cipher cipher = Cipher.getInstance(AES256JNCryptor.AES_CIPHER_ALGORITHM); cipher.init(Cipher.ENCRYPT_MODE, encryptionKey, new IvParameterSpec(iv))...
[ "private", "void", "createStreams", "(", "SecretKey", "encryptionKey", ",", "SecretKey", "hmacKey", ",", "byte", "[", "]", "iv", ",", "OutputStream", "out", ")", "throws", "CryptorException", "{", "this", ".", "iv", "=", "iv", ";", "try", "{", "Cipher", "c...
Creates the cipher and MAC streams required, @param encryptionKey the encryption key @param hmacKey the HMAC key @param iv the IV @param out the output stream we are wrapping @throws CryptorException
[ "Creates", "the", "cipher", "and", "MAC", "streams", "required" ]
5209f10b988e4033c0b769a40b0d6cc99ea16af7
https://github.com/TGIO/RNCryptorNative/blob/5209f10b988e4033c0b769a40b0d6cc99ea16af7/jncryptor/src/main/java/org/cryptonode/jncryptor/AES256JNCryptorOutputStream.java#L128-L151
train
TGIO/RNCryptorNative
jncryptor/src/main/java/org/cryptonode/jncryptor/AES256JNCryptorOutputStream.java
AES256JNCryptorOutputStream.writeHeader
private void writeHeader() throws IOException { /* Write out the header */ if (passwordBased) { macOutputStream.write(AES256JNCryptor.VERSION); macOutputStream.write(AES256Ciphertext.FLAG_PASSWORD); macOutputStream.write(encryptionSalt); macOutputStream.write(hmacSalt); macOutputSt...
java
private void writeHeader() throws IOException { /* Write out the header */ if (passwordBased) { macOutputStream.write(AES256JNCryptor.VERSION); macOutputStream.write(AES256Ciphertext.FLAG_PASSWORD); macOutputStream.write(encryptionSalt); macOutputStream.write(hmacSalt); macOutputSt...
[ "private", "void", "writeHeader", "(", ")", "throws", "IOException", "{", "/* Write out the header */", "if", "(", "passwordBased", ")", "{", "macOutputStream", ".", "write", "(", "AES256JNCryptor", ".", "VERSION", ")", ";", "macOutputStream", ".", "write", "(", ...
Writes the header data to the output stream. @throws IOException
[ "Writes", "the", "header", "data", "to", "the", "output", "stream", "." ]
5209f10b988e4033c0b769a40b0d6cc99ea16af7
https://github.com/TGIO/RNCryptorNative/blob/5209f10b988e4033c0b769a40b0d6cc99ea16af7/jncryptor/src/main/java/org/cryptonode/jncryptor/AES256JNCryptorOutputStream.java#L158-L171
train
TGIO/RNCryptorNative
jncryptor/src/main/java/org/cryptonode/jncryptor/AES256JNCryptorOutputStream.java
AES256JNCryptorOutputStream.write
@Override public void write(int b) throws IOException { if (!writtenHeader) { writeHeader(); writtenHeader = true; } cipherStream.write(b); }
java
@Override public void write(int b) throws IOException { if (!writtenHeader) { writeHeader(); writtenHeader = true; } cipherStream.write(b); }
[ "@", "Override", "public", "void", "write", "(", "int", "b", ")", "throws", "IOException", "{", "if", "(", "!", "writtenHeader", ")", "{", "writeHeader", "(", ")", ";", "writtenHeader", "=", "true", ";", "}", "cipherStream", ".", "write", "(", "b", ")"...
Writes one byte to the encrypted output stream. @param b the byte to write @throws IOException if an I/O error occurs
[ "Writes", "one", "byte", "to", "the", "encrypted", "output", "stream", "." ]
5209f10b988e4033c0b769a40b0d6cc99ea16af7
https://github.com/TGIO/RNCryptorNative/blob/5209f10b988e4033c0b769a40b0d6cc99ea16af7/jncryptor/src/main/java/org/cryptonode/jncryptor/AES256JNCryptorOutputStream.java#L181-L188
train
TGIO/RNCryptorNative
jncryptor/src/main/java/org/cryptonode/jncryptor/TrailerInputStream.java
TrailerInputStream.fillTrailerBuffer
private void fillTrailerBuffer() throws IOException { trailerBuffer = new byte[trailerSize]; if (trailerSize == 0) { return; } int bytesRead = StreamUtils.readAllBytes(in, trailerBuffer); if (bytesRead != trailerBuffer.length) { throw new EOFException(String.format( "Trailer ...
java
private void fillTrailerBuffer() throws IOException { trailerBuffer = new byte[trailerSize]; if (trailerSize == 0) { return; } int bytesRead = StreamUtils.readAllBytes(in, trailerBuffer); if (bytesRead != trailerBuffer.length) { throw new EOFException(String.format( "Trailer ...
[ "private", "void", "fillTrailerBuffer", "(", ")", "throws", "IOException", "{", "trailerBuffer", "=", "new", "byte", "[", "trailerSize", "]", ";", "if", "(", "trailerSize", "==", "0", ")", "{", "return", ";", "}", "int", "bytesRead", "=", "StreamUtils", "....
Populates the trailer buffer with data from the stream. @throws EOFException if the stream finishes before the trailer is read @throws IOException if the underlying stream throws an exception
[ "Populates", "the", "trailer", "buffer", "with", "data", "from", "the", "stream", "." ]
5209f10b988e4033c0b769a40b0d6cc99ea16af7
https://github.com/TGIO/RNCryptorNative/blob/5209f10b988e4033c0b769a40b0d6cc99ea16af7/jncryptor/src/main/java/org/cryptonode/jncryptor/TrailerInputStream.java#L61-L74
train