X Tutup
Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
*/
package org.androidannotations.logger;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;

import org.androidannotations.helper.OptionsHelper;
import org.androidannotations.logger.appender.Appender;
import org.androidannotations.logger.appender.ConsoleAppender;
import org.androidannotations.logger.appender.FileAppender;
import org.androidannotations.logger.appender.MessagerAppender;
import org.androidannotations.logger.formatter.Formatter;

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import java.util.ArrayList;
import java.util.List;

public class LoggerContext {

private static LoggerContext INSTANCE = null;
Expand All @@ -48,10 +47,6 @@ public static LoggerContext getInstance() {
return INSTANCE;
}

LoggerContext() {
appenders.add(new MessagerAppender());
}

public void writeLog(Level level, String loggerName, String message, Element element, AnnotationMirror annotationMirror, Throwable thr, Object... args) {
for (Appender appender : appenders) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i had kept the constructor but as private and the class as final. as this class should never be instanced from somewhere else than getInstance() or am i wrong? - sorry for late comment but during the holidays i was forced to be afk and was unable to comment :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is a singleton class... I'll re-add that right now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by 2964494.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dodgex no problem, thanks for mentioning it! I think it is completely ok to be afk on Christmas holidays. 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WonderCsabo not if you WANT to do some work. ;) but well 🎁 ❤️

Formatter formatter = appender.getFormatter();
Expand All @@ -69,10 +64,12 @@ public void setCurrentLevel(Level currentLevel) {
}

public void setProcessingEnv(ProcessingEnvironment processingEnv) {
appenders.clear();
OptionsHelper optionsHelper = new OptionsHelper(processingEnv);
resolveLogLevel(optionsHelper);
addConsoleAppender(optionsHelper);
addFileAppender(optionsHelper);
appenders.add(new MessagerAppender());

for (Appender appender : appenders) {
appender.setProcessingEnv(processingEnv);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ public synchronized void append(Level level, Element element, AnnotationMirror a
@Override
public void setProcessingEnv(ProcessingEnvironment processingEnv) {
super.setProcessingEnv(processingEnv);
if (file == null) {
resolveLogFile();
}
resolveLogFile();
}

private void resolveLogFile() {
Expand Down
X Tutup