Skip to content

Commit

Permalink
[lang] Add getKernelLogger function into the Bootstrap.
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Jun 2, 2019
1 parent 9dc4e3b commit 6bf3c41
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Expand Up @@ -113,6 +113,7 @@ public static ServiceLoader<SREBootstrap> getServiceLoader(boolean onlyInstalled
* @return the set of libraries.
* @since 0.7
*/
@Pure
public static Set<URL> getBootstrappedLibraries() {
final String name = PREFIX + SREBootstrap.class.getName();
final Set<URL> result = new TreeSet<>();
Expand Down
Expand Up @@ -22,6 +22,9 @@
package io.sarl.bootstrap;

import java.util.UUID;
import java.util.logging.Logger;

import org.eclipse.xtext.xbase.lib.Pure;

import io.sarl.lang.core.Agent;
import io.sarl.lang.core.AgentContext;
Expand Down Expand Up @@ -83,6 +86,7 @@ public interface SREBootstrap {
* @return the identifier of the boot agent, or <code>null</code> if it is unknown.
* @see #startAgent(int, Class, Object...)
*/
@Pure
UUID getBootAgentIdentifier();

/** Replies if the bootstrap could be used.
Expand All @@ -91,6 +95,7 @@ public interface SREBootstrap {
*
* @return {@code true} if the bootstrap could be used. {@code false} if it cannot be used.
*/
@Pure
default boolean isActive() {
return true;
}
Expand Down Expand Up @@ -183,6 +188,7 @@ default void setUniverseContextUUID(UUID id) {
* @return the identifier, or {@code null} if no identifier is provided by the user and the default identifier should be used.
* @since 0.9
*/
@Pure
default UUID getUniverseContextUUID() {
throw new UnsupportedOperationException();
}
Expand All @@ -208,6 +214,7 @@ default void setUniverseSpaceUUID(UUID id) {
* @return the identifier, or {@code null} if no identifier is provided by the user and the default identifier should be used.
* @since 0.9
*/
@Pure
default UUID getUniverseSpaceUUID() {
throw new UnsupportedOperationException();
}
Expand All @@ -224,4 +231,16 @@ default void setVerboseLevel(int level) {
throw new UnsupportedOperationException();
}

/** Replies the logger used by the SRE.
*
* <p>This function replies a not {@code null} value only if the kernel was launched.
*
* @return the logger, or {@code null} if the kernel was not launched or has no logger.
* @since 0.10
*/
@Pure
default Logger getKernelLogger() {
return null;
}

}
Expand Up @@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.logging.Logger;

import io.janusproject.kernel.Kernel;

Expand Down Expand Up @@ -105,6 +106,18 @@ public AgentContext startWithoutAgent() {
return kern.getJanusContext();
}

@Override
public Logger getKernelLogger() {
final Kernel kern;
synchronized (this) {
kern = this.kernel;
}
if (kern != null) {
return kern.getLogger();
}
return null;
}

@Override
public void setOffline(boolean isOffline) {
Boot.setOffline(isOffline);
Expand Down

0 comments on commit 6bf3c41

Please sign in to comment.