Search in sources :

Example 1 with LoggerCache

use of com.oracle.truffle.polyglot.PolyglotLoggers.LoggerCache in project graal by oracle.

the class PolyglotEngineImpl method getOrCreateEngineLoggers.

Object getOrCreateEngineLoggers() {
    Object res = engineLoggers;
    if (res == null) {
        synchronized (this.lock) {
            res = engineLoggers;
            if (res == null) {
                LoggerCache loggerCache = PolyglotLoggers.LoggerCache.newEngineLoggerCache(this);
                loggerCache.setOwner(this);
                res = LANGUAGE.createEngineLoggers(loggerCache);
                if (!logLevels.isEmpty()) {
                    EngineAccessor.LANGUAGE.configureLoggers(this, logLevels, res);
                }
                for (ContextWeakReference contextRef : contexts) {
                    PolyglotContextImpl context = contextRef.get();
                    if (context != null && !context.config.logLevels.isEmpty()) {
                        LANGUAGE.configureLoggers(context, context.config.logLevels, res);
                    }
                }
                engineLoggers = res;
            }
        }
    }
    return res;
}
Also used : LoggerCache(com.oracle.truffle.polyglot.PolyglotLoggers.LoggerCache) ContextWeakReference(com.oracle.truffle.polyglot.PolyglotContextImpl.ContextWeakReference)

Example 2 with LoggerCache

use of com.oracle.truffle.polyglot.PolyglotLoggers.LoggerCache in project graal by oracle.

the class PolyglotEngineImpl method getEngineLogger.

TruffleLogger getEngineLogger() {
    TruffleLogger result = this.engineLogger;
    if (result == null) {
        synchronized (this.lock) {
            result = this.engineLogger;
            if (result == null) {
                result = this.engineLoggerSupplier.apply(OPTION_GROUP_ENGINE);
                Object logger = EngineAccessor.LANGUAGE.getLoggerCache(result);
                LoggerCache loggerCache = (LoggerCache) EngineAccessor.LANGUAGE.getLoggersSPI(logger);
                loggerCache.setOwner(this);
                if (!logLevels.isEmpty()) {
                    EngineAccessor.LANGUAGE.configureLoggers(this, logLevels, logger);
                }
                this.engineLogger = result;
            }
        }
    }
    return result;
}
Also used : TruffleLogger(com.oracle.truffle.api.TruffleLogger) LoggerCache(com.oracle.truffle.polyglot.PolyglotLoggers.LoggerCache)

Aggregations

LoggerCache (com.oracle.truffle.polyglot.PolyglotLoggers.LoggerCache)2 TruffleLogger (com.oracle.truffle.api.TruffleLogger)1 ContextWeakReference (com.oracle.truffle.polyglot.PolyglotContextImpl.ContextWeakReference)1