Sets schedulers for API calls observables and adds logging.

@param obs Observable to set schedulers for.
@param log Logger instance.
@param <E> Class of the service call result.
@return Observable for API call.
5774
<E> Observable<E> wrapObservable(@NonNull Observable<E> obs, @NonNull Logger log, final String msg) {
        return obs.subscribeOn(Schedulers.io()).observeOn(Schedulers.io())
                .doOnNext(r -> log(log, (ComapiResult) r, msg))
                .doOnError(t -> log(log, t, msg));
    }
1345980
public static <T> Observable.Transformer<T, T> applyLogging(final String name, final Logger logger){
        return new Observable.Transformer<T, T>() {
            @Override
            public Observable<T> call(Observable<T> observable) {
                return observable
                        .doOnNext(new Action1<T>() {
                            @Override
                            public void call(T t) {
                                logger.log(Log.DEBUG, "[%s] onNext(%s)", name, t);
                            }
                        })
                        .doOnError(new Action1<Throwable>() {
                            @Override
                            public void call(Throwable throwable) {
                                logger.log(throwable, Log.DEBUG, "[%s] onError()", name);
                            }
                        })
                        .doOnCompleted(new Action0() {
                            @Override
                            public void call() {
                                logger.log(Log.DEBUG, "[%s] onCompleted()", name);
                            }
                        });
            }
        };
    }
1324157
public static <T> Observable<T> toObservable(EventPublisher<T> eventPublisher) {
        PublishSubject<T> publishSubject = PublishSubject.create();
        Subject<T> serializedSubject = publishSubject.toSerialized();
        eventPublisher.onEvent(serializedSubject::onNext);
        return serializedSubject;
    }
1332295
public static <T> ObservableTransformer<T,T> doOnNextFx(Consumer<T> onNext) {
        return obs -> obs.doOnNext(t -> runOnFx(t, onNext));
    }
366138
Observable<File> mergeLogs(@NonNull File mergedFile) {

        return Observable.fromCallable(() -> {
            synchronized (sharedLock) {
                try {
                    mergeFiles(mergedFile);
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    sharedLock.notifyAll();
                }
            }
            return mergedFile;
        }).subscribeOn(Schedulers.from(executor));
    }
790952
private Observable<String> loadLogsObservable() {

        return Observable.fromCallable(() -> {

            StringBuilder sb = new StringBuilder();

            Context context = appContextRef.get();

            if (context != null) {

                synchronized (sharedLock) {

                    try {

                        File dir = context.getFilesDir();

                        String line;

                        for (int i = 1; i <= maxFiles; i++) {

                            File file = new File(dir, name(i));

                            if (file.exists()) {
                                inputStream = new FileInputStream(file);
                                BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
                                while ((line = reader.readLine()) != null) {
                                    sb.append(line).append('\n');
                                }
                                reader.close();
                            }
                        }
                    } catch (Exception e) {
                        throw Exceptions.propagate(e);
                    } finally {
                        sharedLock.notifyAll();
                    }
                }
            }

            return sb.toString();
        });
    }
264811
Logger demandLogger(String name, String resourceBundleName, Class<?> caller) {
        Logger result = getLogger(name);
        if (result == null) {
            // only allocate the new logger once
            Logger newLogger = new Logger(name, resourceBundleName, caller);
            do {
                if (addLogger(newLogger)) {
                    // We successfully added the new Logger that we
                    // created above so return it without refetching.
                    return newLogger;
                }

                // We didn't add the new Logger that we created above
                // because another thread added a Logger with the same
                // name after our null check above and before our call
                // to addLogger(). We have to refetch the Logger because
                // addLogger() returns a boolean instead of the Logger
                // reference itself. However, if the thread that created
                // the other Logger is not holding a strong reference to
                // the other Logger, then it is possible for the other
                // Logger to be GC'ed after we saw it in addLogger() and
                // before we can refetch it. If it has been GC'ed then
                // we'll just loop around and try again.
                result = getLogger(name);
            } while (result == null);
        }
        return result;
    }
999483
public static <T> Observer<? super T> log() {
        return new Observer<T>() {

            @Override
            public void onCompleted() {
                // do nothing
            }

            @Override
            public void onError(Throwable e) {
                log.error(e.getMessage(), e);
            }

            @Override
            public void onNext(T t) {
                log.info(t + "");
            }
        };
    }
509333
@Route(method = HttpMethod.GET, uri = "/monitor/logs/loggers")
    public Result loggers() {
        LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
        List<LoggerModel> loggers = new ArrayList<>();
        for (Logger logger : context.getLoggerList()) {
            loggers.add(new LoggerModel(logger));
        }
        return ok(loggers).json();
    }
143917
public void setLogRecord(java.util.Map<String, String> logRecord) {
        this.logRecord = logRecord == null ? null : new com.amazonaws.internal.SdkInternalMap<String, String>(logRecord);
    }
1223750
public ProxyDataSourceBuilder logQueryByJUL(Level logLevel, String julLoggerName) {
        this.createJulQueryListener = true;
        this.julLogLevel = logLevel;
        this.julLoggerName = julLoggerName;
        return this;
    }
182433
private Logger createLoggerInstance(String loggerName) throws Exception
    {
        Class loggerClass = getConfiguration().getLoggerClass();
        Logger log = (Logger) ClassHelper.newInstance(loggerClass, String.class, loggerName);
        log.configure(getConfiguration());
        return log;
    }
584257
private void startLogScheduler() {
    this.logScheduler.scheduleAtFixedRate(
        new Runnable() {
          @Override
          public void run() {
            CLRBufferedLogHandler.this.logAll();
          }
        }, 0, LOG_SCHEDULE_PERIOD, TimeUnit.SECONDS);
  }
1278641
public Spider setScheduler(Scheduler scheduler) {
        checkIfRunning();
        Scheduler oldScheduler = this.scheduler;
        this.scheduler = scheduler;
        if (oldScheduler != null) {
            Request request;
            while ((request = oldScheduler.poll(this)) != null) {
                this.scheduler.push(request, this);
            }
        }
        return this;
    }
298762
@Override
	public void registerIrObs(IREventObserver obs)
	{
		if (obs != null && irObserver == null)
		{
			irObserver = obs;
		}
	}
286365
public static <T> Observable.Transformer<T, T> applySchedulers(final Scheduler subscribeScheduler) {
        return new Observable.Transformer<T, T>() {
            @Override
            public Observable<T> call(Observable<T> observable) {
                return observable.subscribeOn(subscribeScheduler)
                        .observeOn(AndroidSchedulers.mainThread());
            }
        };
    }
182928
@Override
    public void setObserver(HttpOutputStreamObserver obs) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "obs  ->" + obs);
        }
        this.obs = obs;
    }