Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to completely disable to BOY console; prints to log instead #7

Merged
merged 2 commits into from
Feb 15, 2021
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 @@ -53,18 +53,18 @@ public class ConsoleServiceSSHelperImpl extends ConsoleServiceSSHelper {
private IOConsoleOutputStream errorStream, warningStream, infoStream, generalStream;

{
console = new IOConsole("BOY Console", null);

generalStream = console.newOutputStream();

// Values are from https://bugs.eclipse.org/bugs/show_bug.cgi?id=46871#c5
console.setWaterMarks(400000, 500000);

ConsolePlugin consolePlugin = ConsolePlugin.getDefault();
consolePlugin.getConsoleManager().addConsoles(
new IConsole[] { console });


if (PreferencesHelper.getConsolePopupLevel() != PreferencesHelper.ConsolePopupLevel.NO_CONSOLE) {
console = new IOConsole("BOY Console", null);
generalStream = console.newOutputStream();
// Values are from https://bugs.eclipse.org/bugs/show_bug.cgi?id=46871#c5
console.setWaterMarks(400000, 500000);
ConsolePlugin consolePlugin = ConsolePlugin.getDefault();
consolePlugin.getConsoleManager().addConsoles(
new IConsole[] { console });
}
}

/**
Expand Down Expand Up @@ -117,10 +117,14 @@ private String getTimeString(){
*/
@Override
public void writeError(final String message){

switch (PreferencesHelper.getConsolePopupLevel()) {
case ALL:
popConsoleView();
break;
case NO_CONSOLE:
OPIBuilderPlugin.getLogger().log(Level.WARNING, message);

Choose a reason for hiding this comment

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

Suggested change
OPIBuilderPlugin.getLogger().log(Level.WARNING, message);
OPIBuilderPlugin.getLogger().log(Level.ERROR, message);

Copy link
Author

Choose a reason for hiding this comment

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

I agree that this would be nice, but unfortunately it doesn't compile as ERROR isn't a valid errorlevel. WARNING felt like the most appropriate from this list: https://docs.oracle.com/javase/7/docs/api/java/util/logging/Level.html. We could use SEVERE but that doesn't exist in log4j world so would get logged as INFO anyway - I preferred to stick with levels that exist in both...

return;
default:
break;
}
Expand All @@ -147,14 +151,19 @@ public void run() {
*/
@Override
public void writeWarning(String message){

final String output = getTimeString() + " WARNING: " + message+ ENTER;
switch (PreferencesHelper.getConsolePopupLevel()) {
case ALL:
popConsoleView();
break;
case NO_CONSOLE:
OPIBuilderPlugin.getLogger().log(Level.WARNING, message);
return;
default:
break;
}

UIBundlingThread.getInstance().addRunnable(new Runnable() {

@Override
Expand All @@ -175,15 +184,20 @@ public void run() {
*/
@Override
public void writeInfo(String message){

final String output = getTimeString() + " INFO: " + message+ ENTER;
switch (PreferencesHelper.getConsolePopupLevel()) {
case ALL:
case ONLY_INFO:
popConsoleView();
break;
case NO_CONSOLE:
OPIBuilderPlugin.getLogger().log(Level.INFO, message);
return;
default:
break;
}

UIBundlingThread.getInstance().addRunnable(new Runnable(){
@Override
public void run() {
Expand All @@ -200,6 +214,12 @@ public void run() {

@Override
public void writeString(final String s){
if (PreferencesHelper.getConsolePopupLevel() == PreferencesHelper.ConsolePopupLevel.NO_CONSOLE) {
// If we are not writing to the console, send it to logger instead.
OPIBuilderPlugin.getLogger().log(Level.INFO, s);
return;
}

UIBundlingThread.getInstance().addRunnable(new Runnable(){
@Override
public void run() {
Expand All @@ -215,6 +235,13 @@ public void run() {

@Override
public void writeString(final String s, final RGB color){

if (PreferencesHelper.getConsolePopupLevel() == PreferencesHelper.ConsolePopupLevel.NO_CONSOLE) {
// If we are not writing to the console, send it to logger instead.
OPIBuilderPlugin.getLogger().log(Level.INFO, s);
return;
}

UIBundlingThread.getInstance().addRunnable(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
public class PreferencesHelper {

public enum ConsolePopupLevel {
NO_CONSOLE,
NO_POP,
ONLY_INFO,
ALL;
Expand Down