Search in sources :

Example 1 with LogRecorder

use of hudson.logging.LogRecorder in project support-core-plugin by jenkinsci.

the class JenkinsLogs method addLogRecorders.

/**
 * Dumps the content of {@link LogRecorder}, which is the groups of loggers configured
 * by the user. The contents are also ring buffer and only remembers recent 256 or so entries.
 */
private void addLogRecorders(Container result) {
    for (Map.Entry<String, LogRecorder> entry : logRecorders.entrySet()) {
        String name = entry.getKey();
        String entryName = "nodes/master/logs/custom/" + name + ".log";
        File storedFile = new File(customLogs, name + ".log");
        if (storedFile.isFile()) {
            result.add(new FileContent(entryName, storedFile));
        } else {
            // Was not stored for some reason; fine, just load the memory buffer.
            final LogRecorder recorder = entry.getValue();
            result.add(new LogRecordContent(entryName) {

                @Override
                public Iterable<LogRecord> getLogRecords() {
                    return recorder.getLogRecords();
                }
            });
        }
    }
}
Also used : FileContent(com.cloudbees.jenkins.support.api.FileContent) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File) LogRecorder(hudson.logging.LogRecorder)

Aggregations

FileContent (com.cloudbees.jenkins.support.api.FileContent)1 LogRecorder (hudson.logging.LogRecorder)1 File (java.io.File)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1