Coder Social home page Coder Social logo

commons-log-view's Introduction

日志监控

日志查看服务

maven引用

<dependency>
    <groupId>io.github.moon-cn</groupId>
    <artifactId>commons-log-view</artifactId>
    <version>1.0.x</version>
</dependency>

配置请求路径(可选)

log-view:
  # websocket监听文件变化的请求路径
  websocket: /api/log-view

访问

项目启动,访问

http://127.0.0.1:8080/log-view/index.html?path=D:/demo.log

websocket接口

一个session对应一个监控线程,session断开线程关闭

请求格式

ws://127.0.0.1:8080/api/log?path=要实时监控的文件路径

使用

可参考demo.html,自行实现前端代码

    webSocket = new WebSocket(target);
    webSocket.onopen = function () {
        console.log("已连接");
    };
    webSocket.onmessage = function (event) {
        console.log(event.data);
    };
    webSocket.onclose = function (e) {
        console.log("连接关闭", e);
    };

如果简单使用,可在页面中嵌入 iframe

例如 http://127.0.0.1:8080/log-view/index.html?path=D:/demo.log, 其中path需要encode

img.png

import React from 'react';
import { render } from 'react-dom';
import { LazyLog, ScrollFollow } from 'react-lazylog';

render((
  <ScrollFollow
    startFollowing={true}
    render={({ follow, onScroll }) => (
      <LazyLog url="http://127.0.0.1/api/log?path=D:\demo.log" stream follow={follow} onScroll={onScroll} />
    )}
  />
), document.getElementById('root'));

commons-log-view's People

Contributors

mxvc avatar meethigher avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.