当前位置: 首页>>代码示例>>Java>>正文


Java Logging类代码示例

本文整理汇总了Java中com.github.davidmoten.rx.slf4j.Logging的典型用法代码示例。如果您正苦于以下问题:Java Logging类的具体用法?Java Logging怎么用?Java Logging使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Logging类属于com.github.davidmoten.rx.slf4j包,在下文中一共展示了Logging类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DriftingLayer

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public DriftingLayer() {
    log.info("creating Drifting layer");
    // collect drifting candidates
    String filename = System.getProperty("drift.candidates", System.getProperty("user.home")
            + "/drift-candidates.txt");
    Sources.fixes2(new File(filename))
            // log
            .lift(Logging.<VesselPosition> logger().showCount().showMemory().every(10000).log())
            // only emit those drifters that have drifted a decent distance
            // since start of drift
            .lift(new OperatorDriftDistanceCheck())
            // only class A vessels
            .filter(onlyClassA())
            // exclude anchored
            .filter(not(atAnchor()))
            // exclude moored
            .filter(not(isMoored()))
            // group by id and date
            .distinct(byIdAndTimePattern("yyyy-MM-dd HH"))
            // add to queue
            .doOnNext(addToQueue())
            // run in background
            .subscribeOn(Schedulers.io())
            // subscribe
            .subscribe(createObserver());
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:27,代码来源:DriftingLayer.java

示例2: getCandidatesForAStream

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public static Observable<CollisionCandidate> getCandidatesForAStream(
        Observable<VesselPosition> o) {
    // make a window of recent positions indexed spatially

    return Observable.defer(() -> o.scan(new State(), nextState())
            // log
            .lift(Logging.<State> logger().showCount("positions")
                    .showRateSince("rate (pos/s)", TimeUnit.SECONDS.toMillis(10))
                    .showRateSinceStart("overall rate").every(10000).showValue()
                    .value(state -> "state.map.size=" + state.mapSize() + ", state.rtree.size="
                            + state.tree().size())
                    .log())
            // report collision candidates from each window for the latest
            // reported position
            .flatMap(toCollisionCandidatesForPosition())
            // group by id of first candidate
            .groupBy(byIdPair())
            // only show if repeated
            .flatMap(onlyRepeating()));
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:21,代码来源:CollisionDetector.java

示例3: main

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public static void main(String[] args) throws FileNotFoundException, IOException {
    System.out.println(Options.instance());
    String filename = "/media/an/nmea/2013/NMEA_ITU_20130108.gz";
    Streams.extractFixes(Streams.nmeaFromGzip(filename))
            // parse positions
            // .compose(AisVesselPositions.positions())
            // log
            .lift(Logging.<HasFix> logger().showCount().every(100000).log())
            // group by mmsi
            .groupBy(f -> f.fix().mmsi())
            //
            .flatMap(o -> o.compose(DriftDetector.detectDrift())
                    .compose(Downsample.minTimeStep(5, TimeUnit.MINUTES, isStartOfDrift())))
            //
            .count()
            //
            .doOnNext(System.out::println)
            //
            .doOnError(System.err::println)
            //
            .subscribe();
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:23,代码来源:DriftDetectorMain.java

示例4: normalize

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
private static Observable<Entry<Object, Point>> normalize(
        Observable<Entry<Object, Point>> entries, final Box bounds) {
    return entries.map(new Func1<Entry<Object, Point>, Entry<Object, Point>>() {
        @Override
        public Entry<Object, Point> call(Entry<Object, Point> entry) {
            return Entry.entry(entry.value(), bounds.normalize(entry.geometry()));
        }
    }).lift(Logging.<Entry<Object, Point>> logger().showCount().showMemory().every(100000)
            .log());
}
 
开发者ID:davidmoten,项目名称:rtree-3d,代码行数:11,代码来源:RTree3DTest.java

示例5: main

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    long start = ZonedDateTime
            .from(DateTimeFormatter.ISO_DATE_TIME.parse("2014-05-13T00:00:00Z")).toEpochSecond()
            * 1000;
    long finish = ZonedDateTime
            .from(DateTimeFormatter.ISO_DATE_TIME.parse("2014-05-27T00:00:00Z")).toEpochSecond()
            * 1000;

    Pattern pattern = Pattern.compile(".*\\.track");
    PrintStream out = new PrintStream("target/output.txt");
    out.println("mmsi\ttime\tlat\tlong\tcourse\tspeedKnots");
    List<File> files = Files.find(new File("/media/an/binary-fixes-5-minute/2014"), pattern);
    Observable.from(files)
            //
            .flatMap(file -> extract(file, start, finish).subscribeOn(Schedulers.computation()))
            // only valid mmsi
            .filter(fix -> MmsiValidator2.INSTANCE.isValid(fix.mmsi()))
            //
            .map(f -> String.format("%s\t%s\t%s\t%s\t%s\t%s", f.mmsi(),
                    formatDateTime(f.time()), f.lat(), f.lon(),
                    get(f.courseOverGroundDegrees()), get(f.speedOverGroundKnots())))
            //
            // .doOnNext(System.out::println)
            //
            .doOnNext(out::println)
            //
            .lift(Logging.<String> logger().showCount().every(10000).log())
            //
            .count()
            //
            .doOnTerminate(out::close)
            //
            .toBlocking().single();
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:35,代码来源:AdHocMain.java

示例6: sortBinaryFixFilesByTime

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public static Observable<Integer> sortBinaryFixFilesByTime(File output,
        final long downSampleIntervalMs, Scheduler scheduler) {
    final AtomicInteger numFiles = new AtomicInteger();
    final AtomicLong totalSizeBytes = new AtomicLong();
    final Action1<File> preSortAction = createLogAction(numFiles, totalSizeBytes);
    return Observable.just(output)
            // log
            .lift(Logging.<File> logger().prefix("sorting files in folder ").log())
            // find the track files
            .concatMap(findTrackFiles(numFiles, totalSizeBytes))
            // sort the fixes in each file in each list and rewrite files
            .flatMap(sortFileFixes(downSampleIntervalMs, scheduler, preSortAction))
            // return the count
            .count();
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:16,代码来源:BinaryFixes.java

示例7: main

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public static void main(String[] args) throws IOException {

        // open an output writer
        final Writer writer = new FileWriter("/media/an/fixes.libsvm");

        // specify which files have the fixes to process
        List<File> files = Files.find(new File("/media/an/binary-fixes-5-minute/2014"),
                Pattern.compile(".*\\.track"));

        // process the fixes in the files
        BinaryFixes.from(files)
        // log
                .lift(Logging.<HasFix> logger().showCount().every(1000000).log())
                // just class A vessels
                .filter(classAOnly())
                // only fixes that have course, heading and speed present
                .filter(hasCourseHeadingSpeed())
                // emit with params
                .lift(new OperatorMinEffectiveSpeedThreshold(TimeUnit.HOURS.toMillis(1)))
                // log
                // write the fixes in LIBSVM format
                .forEach(writeFix(writer), t -> t.printStackTrace());

        // close the writer
        writer.close();

        System.out.println("finished");
    }
 
开发者ID:amsa-code,项目名称:risky,代码行数:29,代码来源:LibSvmMain.java

示例8: main

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public static void main(String[] args) {
    // perform a speed test for loading BinaryFixes from disk

    FixImpl.validate = false;
    final ConcurrentHashMap<Long, List<FixImpl>> map = new ConcurrentHashMap<Long, List<FixImpl>>();
    // -downsample-5-mins
    List<File> files = Files.find(
            new File("/media/an/binary-fixes/2014-year-downsample-5-mins"),
            Pattern.compile(".*\\.track"));
    long t = System.currentTimeMillis();
    long count = Observable
    // list files
            .from(files)
            // share the load between processors
            .buffer(Math.max(1, files.size() / Runtime.getRuntime().availableProcessors()))
            // count each file asynchronously
            .flatMap(
                    list -> {
                        return Observable.from(list)
                                .concatMap(file -> BinaryFixes.from(file).countLong())
                                // schedule
                                .subscribeOn(Schedulers.computation());
                    })
            // total counts
            .scan(0L, (a, b) -> a + b)
            // log count so far
            .lift(Logging.<Long> logger().showCount().prefix("records=").showMemory()
                    .every(1000).log())
            // get last count (total)
            .last()
            // block and get
            .toBlocking().single();
    long elapsed = System.currentTimeMillis() - t;
    System.out.println("Map size = " + map.size());
    System.out.println("Total records = " + count + ", numPerSecond=" + count * 1000.0
            / elapsed + ", timeMs=" + elapsed);
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:38,代码来源:BinaryFixesMain.java

示例9: getDriftingPositions

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
private static Observable<VesselPosition> getDriftingPositions(Observable<String> filenames) {
    return filenames
    // get the positions from each file
    // use concatMap till merge bug is fixed RxJava
    // https://github.com/ReactiveX/RxJava/issues/1941
    // log filename
            .lift(Logging.<String> logger().onNextPrefix("loading file=").showValue().log())
            // extract positions from file
            .flatMap(filenameToDriftCandidates())
            // convert back to vessel position
            .map(driftCandidateToVesselPosition())
            // log
            // .lift(Logging.<VesselPosition>logger().log())
            // only class A vessels
            .filter(onlyClassA())
            // ignore vessels at anchor
            .filter(not(atAnchor()))
            // ignore vessels at moorings
            .filter(not(isMoored()))
            // ignore vessels that might be fishing
            .filter(not(isShipType(SHIP_TYPE_FISHING)))
            // ignore vessels that might be dredging
            .filter(not(isShipType(SHIP_TYPE_DREDGING_OR_UNDERWATER_OPERATIONS)))
            // ignore tugs
            .filter(not(isShipType(SHIP_TYPE_TUG)))
            // ignore military
            .filter(not(isShipType(SHIP_TYPE_MILITARY_OPERATIONS)))
            // ignore military
            .filter(not(isShipType(SHIP_TYPE_LAW_ENFORCEMENT)))
            // is a big vessel
            .filter(isBig())
            // group by id and date
            .distinct(byIdAndTimePattern("yyyy-MM-dd"));
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:35,代码来源:DriftingLayer.java

示例10: main

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public static void main(String[] args) throws FileNotFoundException, IOException,
        InterruptedException {

    getDrifters()
    // log
            .lift(Logging.<VesselPosition> logger().showCount()
                    .showRateSinceStart("msgPerSecond").showMemory().every(5000).log())
            // subscribe
            .subscribe(new Subscriber<VesselPosition>() {

                @Override
                public void onStart() {
                }

                @Override
                public void onCompleted() {
                    // TODO Auto-generated method stub

                }

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

                @Override
                public void onNext(VesselPosition vp) {
                    if (vp.shipType().isPresent() && false) {
                        System.out.println(vp.id() + "," + vp.shipType() + ","
                                + ShipTypeDecoder.getShipType(vp.shipType().get())
                                + ", length=" + vp.lengthMetres() + ", cog=" + vp.cogDegrees()
                                + ", heading=" + vp.headingDegrees() + ", speedKnots="
                                + (vp.speedMetresPerSecond().get() / 1852.0 * 3600));
                    }
                }
            });

    Thread.sleep(10000000);
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:41,代码来源:DriftingLayer.java

示例11: main

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public static void main(String[] args) throws IOException {

        final PrintWriter out = new PrintWriter(new OutputStreamWriter(
                new FileOutputStream("target/destinations.txt"), Charset.forName("UTF-8")));

        File[] files = new File("/media/analysis/nmea/2013")
                .listFiles(f -> f.getName().endsWith(".gz"));
        Arrays.sort(files, (f1, f2) -> f1.getName().compareTo(f2.getName()));
        Observable<File> fileList = Observable.from(files)
                .lift(Logging.<File> logger().showValue().log());
        final AtomicInteger count = new AtomicInteger();
        Observable<Observable<String>> nmeas = Streams.nmeasFromGzip(fileList);
        nmeas.flatMap(nmea -> getDestinations(nmea.doOnNext(line -> {
            int n = count.incrementAndGet();
            if (n % 1000000 == 0)
                System.out.println("lines read=" + (n / 1000000) + "m");
        })))
                // non null
                .filter(line -> {
                    if (line == null)
                        System.out.println("line is null!");
                    return line != null;
                }).distinct().doOnNext(destination -> {
                    out.println(destination);
                    out.flush();
                }).lift(Logging.<String> logger().showCount().showValue().showMemory().every(100)
                        .log())
                .count().toBlocking().single();
        out.close();
    }
 
开发者ID:amsa-code,项目名称:risky,代码行数:31,代码来源:Collator.java

示例12: call

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
@Override
public Observable<Integer> call(Observable<Integer> o) {
    return o.lift(Logging.<Integer> logger().showValue().log());
}
 
开发者ID:davidmoten,项目名称:rxjava-slf4j,代码行数:5,代码来源:LoggingHelperTest.java

示例13: writeFixesFromNmeaGz

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public static Observable<Integer> writeFixesFromNmeaGz(File input, Pattern inputPattern,
        File output, int logEvery, int writeBufferSize, Scheduler scheduler,
        int linesPerProcessor, long downSampleIntervalMs, Func1<Fix, String> fileMapper) {

    final List<File> fileList = Files.find(input, inputPattern);
    Observable<File> files = Observable.from(fileList);

    // count files across parallel streams
    // OperatorLogging<File> logger = Logging.<File> logger().showCount()
    // .showRateSinceStart("rateFilesPerSecond").showValue().log();
    Action1<File> logger = new Action1<File>() {
        AtomicInteger count = new AtomicInteger();
        Long start = null;

        @Override
        public void call(File file) {
            if (start == null)
                start = System.currentTimeMillis();
            int num = count.incrementAndGet();
            double filesPerSecond = (System.currentTimeMillis() - start) / (double) num
                    / 1000.0;
            log.info("file " + num + " of " + fileList.size() + ", " + file.getName()
                    + ", rateFilesPerSecond=" + filesPerSecond);
        }
    };

    deleteDirectory(output);

    return files
            // log the filename
            .buffer(Math.max(fileList.size() / Runtime.getRuntime().availableProcessors(), 1))
            // extract fixes
            .flatMap(extractFixesFromNmeaGzAndAppendToFile(linesPerProcessor, scheduler,
                    fileMapper, writeBufferSize, logger), 1)
            // count number written fixes
            .scan(0, (a, b) -> a + b)
            // log
            .lift(Logging.<Integer> logger().showCount().showMemory()
                    .showRateSince("rate", 5000).every(logEvery).log())
            // get the final count
            .last()
            // on completion of writing fixes, sort the track files and emit
            // the count of files
            .doOnCompleted(
                    () -> log.info("completed converting nmea to binary fixes, starting sort"))
            .concatWith(BinaryFixes.sortBinaryFixFilesByTime(output, downSampleIntervalMs,
                    scheduler));
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:49,代码来源:Streams.java

示例14: writeStaticDataToFile

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public static Observable<AisShipStatic> writeStaticDataToFile(List<File> files, File outputFile,
        Scheduler scheduler) {
    Func0<PrintStream> resourceFactory = Checked.f0(() -> new PrintStream(outputFile));
    Func1<PrintStream, Observable<AisShipStatic>> observableFactory = out -> Observable
            .from(files)
            // buffer into chunks for each processor
            .buffer(Math.max(1, files.size() / Runtime.getRuntime().availableProcessors() - 1))
            .flatMap(
                    list -> Observable.from(list) //
                            .lift(Logging.<File> logger().showValue().showMemory().log()) //
                            .concatMap(
                                    file -> Streams.extract(Streams.nmeaFromGzip(file)) //
                                            .flatMap(aisShipStaticOnly) //
                                            .map(m -> m.getMessage().get().message()) //
                                            .distinct(m -> m.getMmsi()) //
                                            .doOnError(e -> System.err.println("could not read "
                                                    + file + ": " + e.getMessage())) //
                            .onErrorResumeNext(Observable.<AisShipStatic> empty())) //
                    .distinct(m -> m.getMmsi()) //
                    .subscribeOn(scheduler)) //
            .distinct(m -> m.getMmsi()) //
            .compose(Transformers.mapWithIndex()) //
            .doOnNext(indexed -> {
                if (indexed.index() == 0) {
                    out.println(
                            "# MMSI, IMO, AisClass, AisShipType, MaxPresentStaticDraughtMetres, DimAMetres, DimBMetres, DimCMetres, DimDMetres, LengthMetres, WidthMetres, Name");
                    out.println("# columns are tab delimited");
                    out.println("# -1 = not present");
                }
            })
            //
            .map(indexed -> indexed.value())
            //
            .doOnNext(m -> {
                out.format("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", m.getMmsi(),
                        getImo(m).or(-1), m instanceof AisShipStaticA ? "A" : "B",
                        m.getShipType(), getMaximumPresentStaticDraughtMetres(m).or(-1F),
                        m.getDimensionA().or(-1), m.getDimensionB().or(-1),
                        m.getDimensionC().or(-1), m.getDimensionD().or(-1),
                        AisShipStaticUtil.lengthMetres(m).or(-1),
                        AisShipStaticUtil.widthMetres(m).or(-1), prepareName(m.getName()));
                out.flush();
            });

    Action1<PrintStream> disposeAction = out -> out.close();
    return Observable.using(resourceFactory, observableFactory, disposeAction);
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:48,代码来源:ShipStaticDataCreator.java

示例15: main

import com.github.davidmoten.rx.slf4j.Logging; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
    VesselPosition.validate = true;
    CollisionDetector c = new CollisionDetector();
    // String filename = "/media/an/nmea/2013/NMEA_ITU_20130108.gz";
    Map<Integer, Info> ships = ShipStaticData.getMapFromResource("/ship-data-2014.txt");

    // nmea from file
    // Streams.nmeaFromGzip(filename)
    File file = new File("/media/an/daily-fixes/2014/2014-02-01.fix");
    File candidates = new File(
            "/media/an/temp/" + file.getName() + ".collision-candidates.txt");
    try (PrintStream out = new PrintStream(candidates)) {
        out.println("time,mmsi1,lat1, lon1, cog1, m/s, mmsi2, lat2, lon2, cog2, m/s");
        BinaryFixes.from(file, true, BinaryFixesFormat.WITH_MMSI)
                .map(VesselPositions.TO_VESSEL_POSITION)
                .lift(Logging.<VesselPosition> logger().showCount().every(1000).showMemory()
                        .log())
                // only class A
                .filter(onlyClassA)
                // speed must b present
                .filter(p -> p.speedMetresPerSecond().isPresent())
                // course must be present
                .filter(p -> p.cogDegrees().isPresent())
                // ignore tugs, pilots, towing
                .filter(p -> {
                    Mmsi mmsi = (Mmsi) p.id();
                    Optional<Info> info = Optional.fromNullable(ships.get(mmsi.value()));
                    return (!info.isPresent() || !info.get().shipType.isPresent()
                            || !isTugPilotTowing(info.get().shipType.get()));
                })
                // candidates must both be moving more than N knots
                .filter(p -> p.speedKnots().get() >= 5)
                // detect collision candidates
                .compose(CollisionDetector.detectCollisionCandidates())
                // filter
                // .filter(candidatesMovingWithAtLeastSpeedMetresPerSecond(5
                // * 0.5144444))
                // log
                .lift(Logging.<CollisionCandidate> logger().showCount().every(1).showValue()
                        .showMemory().log())
                .doOnNext(cc -> out.format("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", cc.time(),
                        cc.position1().id().uniqueId(), cc.position1().lat(),
                        cc.position1().lon(), cc.position1().cogDegrees(),
                        cc.position1().speedMetresPerSecond().transform(x -> String.valueOf(x))
                                .or(""),
                        cc.position2().id().uniqueId(), cc.position2().lat(),
                        cc.position2().lon(), cc.position2().cogDegrees(),
                        cc.position2().speedMetresPerSecond().transform(x -> String.valueOf(x))
                                .or("")))
                // count
                .count()
                // go
                .toBlocking().single();
    }
}
 
开发者ID:amsa-code,项目名称:risky,代码行数:56,代码来源:CollisionDetectorMain.java


注:本文中的com.github.davidmoten.rx.slf4j.Logging类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。