-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
43 changed files
with
132 additions
and
2,073 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
panda-framework/src/main/java/org/panda_lang/language/interpreter/logging/Channel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright (c) 2020 Dzikoysk | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.panda_lang.language.interpreter.logging; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
import static org.panda_lang.utilities.commons.collection.Lists.add; | ||
|
||
public class Channel implements Comparable<Channel> { | ||
|
||
private static final Collection<Channel> VALUES = new ArrayList<>(); | ||
|
||
public static Channel FATAL = add(VALUES, new Channel("fatal", 6.0)); | ||
public static Channel ERROR = add(VALUES, new Channel("error", 5.0)); | ||
public static Channel WARN = add(VALUES, new Channel("warn", 4.0)); | ||
public static Channel INFO = add(VALUES, new Channel("info", 3.0)); | ||
public static Channel DEBUG = add(VALUES, new Channel("debug", 2.0)); | ||
public static Channel TRACE = add(VALUES, new Channel("trace", 1.0)); | ||
|
||
private final String channel; | ||
private final double priority; | ||
|
||
public Channel(String channel, double priority) { | ||
this.channel = channel; | ||
this.priority = priority; | ||
} | ||
|
||
@Override | ||
public int compareTo(@NotNull Channel o) { | ||
return Double.compare(priority, o.priority); | ||
} | ||
|
||
public double getPriority() { | ||
return priority; | ||
} | ||
|
||
public String getChannel() { | ||
return channel; | ||
} | ||
|
||
public static Channel of(String channel) { | ||
for (Channel value : VALUES) { | ||
if (value.getChannel().equalsIgnoreCase(channel)) { | ||
return value; | ||
} | ||
} | ||
|
||
throw new UnsupportedOperationException(channel + " is not supported by default"); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
panda-framework/src/main/java/org/panda_lang/language/interpreter/logging/Logger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2020 Dzikoysk | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.panda_lang.language.interpreter.logging; | ||
|
||
public interface Logger { | ||
|
||
void log(Channel channel, String message); | ||
|
||
void exception(Throwable throwable); | ||
|
||
default void fatal(String message) { | ||
log(Channel.FATAL, message); | ||
} | ||
|
||
default void error(String message) { | ||
log(Channel.ERROR, message); | ||
} | ||
|
||
default void warn(String message) { | ||
log(Channel.WARN, message); | ||
} | ||
|
||
default void info(String message) { | ||
log(Channel.INFO, message); | ||
} | ||
|
||
default void debug(String message) { | ||
log(Channel.DEBUG, message); | ||
} | ||
|
||
default void trace(String message) { | ||
log(Channel.TRACE, message); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 0 additions & 30 deletions
30
...mework/src/main/java/org/panda_lang/language/interpreter/messenger/FormatterFunction.java
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
...ain/java/org/panda_lang/language/interpreter/messenger/LoggerMessengerOutputListener.java
This file was deleted.
Oops, something went wrong.
82 changes: 0 additions & 82 deletions
82
panda-framework/src/main/java/org/panda_lang/language/interpreter/messenger/Messenger.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.