gvalkov / tailon-legacy

Webapp for looking at and searching through log files
http://tailon-legacy.rtfd.org/
Other
191 stars 44 forks source link

Windows support #11

Open jdrews opened 8 years ago

jdrews commented 8 years ago

This would be really useful for a windows system when working with multiple people and trying to tail text based logs on the file system. e.g. "C:\Program Files\MyApp\MyApp.log"

I tried it on a Windows 10 box, but it doesn't work. The web page comes up and it says it's tailing the file, but nothing shows up when lines are added to the file.

I do see this warning.

c:\Python27\Scripts>tailon.exe -f c:\test.txt -b 127.0.0.1:8032 [+187.999964][ INFO] Listening on 127.0.0.1:8032 No handlers could be found for logger "tornado.general"

jdrews commented 8 years ago

Full disclosure... here is the install log.

c:\Python27\Scripts>pip install tailon
Downloading/unpacking tailon
Downloading/unpacking sockjs-tornado>=1.0.1 (from tailon)
  Downloading sockjs-tornado-1.0.2.tar.gz
  Running setup.py (path:c:\users\jdrews\appdata\local\temp\pip_build_jdrews\sockjs-tornado\setup.py) egg_info for package sockjs-tornado

Downloading/unpacking tornado>=4.2.1 (from tailon)
  Running setup.py (path:c:\users\jdrews\appdata\local\temp\pip_build_jdrews\tornado\setup.py) egg_info for package tornado

    no previously-included directories found matching 'docs\build'
    warning: no files found matching 'tornado\test\README'
Downloading/unpacking PyYAML>=3.11 (from tailon)
  Running setup.py (path:c:\users\jdrews\appdata\local\temp\pip_build_jdrews\PyYAML\setup.py) egg_info for package PyYAML

Downloading/unpacking backports.ssl-match-hostname (from tornado>=4.2.1->tailon)
  Downloading backports.ssl_match_hostname-3.4.0.2.tar.gz
  Running setup.py (path:c:\users\jdrews\appdata\local\temp\pip_build_jdrews\backports.ssl-match-hostname\setup.py) egg_info for package backports.ssl-match-hostname

Downloading/unpacking certifi (from tornado>=4.2.1->tailon)
Installing collected packages: tailon, sockjs-tornado, tornado, PyYAML, backports.ssl-match-hostname, certifi
  Running setup.py install for sockjs-tornado
    Skipping installation of C:\Python27\Lib\site-packages\sockjs\__init__.py (namespace package)

    Installing C:\Python27\Lib\site-packages\sockjs_tornado-1.0.2-py2.7-nspkg.pth
  Running setup.py install for tornado
    building 'tornado.speedups' extension
    Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27
    c:\users\jdrews\appdata\local\temp\pip_build_jdrews\tornado\setup.py:94: UserWarning:
    ********************************************************************
    WARNING: The tornado.speedups extension module could not
    be compiled. No C extensions are essential for Tornado to run,
    although they do result in significant speed improvements for
    websockets.
    The output above this warning shows how the compilation failed.

    Here are some hints for popular operating systems:

    If you are seeing this message on Linux you probably need to
    install GCC and/or the Python development package for your
    version of Python.

    Debian and Ubuntu users should issue the following command:

        $ sudo apt-get install build-essential python-dev

    RedHat, CentOS, and Fedora users should issue the following command:

        $ sudo yum install gcc python-devel

    If you are seeing this message on OSX please read the documentation
    here:

    http://api.mongodb.org/python/current/installation.html#osx
    ********************************************************************

      "The output above "

    no previously-included directories found matching 'docs\build'
    warning: no files found matching 'tornado\test\README'
  Running setup.py install for PyYAML
    checking if libyaml is compilable
    Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27
    skipping build_ext

  Running setup.py install for backports.ssl-match-hostname

Successfully installed tailon sockjs-tornado tornado PyYAML backports.ssl-match-hostname certifi
Cleaning up...

c:\Python27\Scripts>
gvalkov commented 8 years ago

Hello @jdrews,

It's good to see that the installation passes successfully. Problem is that tailon simply doesn't know how to tailor grep through a file on Windows - it relies on external commands to do that.

I can think of the following options at the moment:

I've been meaning to look into this for a long time.

Thanks, G.

jdrews commented 8 years ago

I would lean towards a minimal, cross-platform tail. More requirements (e.g. require MSYS) has the unfortunate consequence of reducing distribution. Especially when you get into information assurance controlled servers. Unless you can bundle it... in which case IA usually won't care/notice and it reduces the workload on end users when installing.

Powershell does have a minimal tailing function. Get-Content <filename> -Wait. It's pretty remedial and annoyingly returns the entire contents of a file and then starts tailing.

gvalkov commented 8 years ago

Yes, that does seem like the way to go. I've successfully bundled a modified version of tailhead with tailon, which seems to work well enough.

This change will probably show up during the weekend, when I have more time for OSS.

Thank you for taking interest in tailon.

jdrews commented 8 years ago

Maybe I'm testing this too early, but I tried out the new tailhead functionality in c0f9663d4205e3ed749b62a2e7e9e9f860bfe3ef on my Windows 10 box. Unfortunately, I don't get any log lines in the browser. Here is a debug output. Oddly enough I never see any running tail message like I do on Linux systems.

C:\Users\jon\Documents>tailon -c tailon.conf -d
[+279.999971][DEBUG] template dir: C:\Python27\lib\site-packages\tailon\templates
[+279.999971][DEBUG] static dir: C:\Python27\lib\site-packages\tailon\assets
[+283.999920][DEBUG] Config:
{'addr': '0.0.0.0',
 'allow-transfers': True,
 'commands': ['tail', 'grep', 'awk'],
 'debug': False,
 'files': OrderedDict([('__ungrouped__', ['c:\\Users\\jon\\Documents\\mylog.log'])]),
 'port': 8049,
 'relative-root': '/'}
[+284.999847][DEBUG] Files:
{'__ungrouped__': ['c:\\Users\\jon\\Documents\\mylog.log']}
[+286.000013][ INFO] Listening on 0.0.0.0:8049
[+341.000080][ INFO] 200 GET /ws/info?t=1446002172496 (127.0.0.1) 2.00ms
[+19023.999929][ INFO] 200 GET / (127.0.0.1) 5.00ms
[+19027.999878][DEBUG] connection closed
[+19233.000040][ INFO] 304 GET /assets/gen/3rdparty.css (127.0.0.1) 116.00ms
[+19234.999895][ INFO] 304 GET /assets/gen/3rdparty.js (127.0.0.1) 1.00ms
[+19236.999989][ INFO] 304 GET /assets/gen/main.js (127.0.0.1) 1.00ms
[+19239.000082][ INFO] 304 GET /assets/gen/main.css (127.0.0.1) 1.00ms
[+19240.999937][ INFO] 304 GET /assets/gen/selectize.css (127.0.0.1) 1.00ms
[+22299.000025][ INFO] 200 GET /ws/info?t=1446002194960 (127.0.0.1) 0.00ms
[+22316.999912][DEBUG] received message: {u'tail': u'c:\\Users\\jon\\Documents\\mylog.log', u'tail-lines': 60}
No handlers could be found for logger "tornado.general"
[+22319.000006][DEBUG] connection closed
[+23325.999975][ INFO] 200 GET /ws/info?t=1446002195987 (127.0.0.1) 0.00ms

I also tried installing tailhead. I'm noticing it throws an error about having to open the file in binary mode on Windows. Perhaps that's the problem?

c:\Users\jon\Documents>pytail -f -s 0.6 c:\Users\jon\Documents\mylog.log
Traceback (most recent call last):
  File "C:\Python27\Scripts\pytail-script.py", line 9, in <module>
    load_entry_point('tailhead==1.0.1', 'console_scripts', 'pytail')()
  File "C:\Python27\lib\site-packages\tailhead\__main__.py", line 76, in main
    _main(args.file, args)
  File "C:\Python27\lib\site-packages\tailhead\__main__.py", line 30, in _main
    lines = tail(f, options.lines)
  File "C:\Python27\lib\site-packages\tailhead\__init__.py", line 321, in tail
    return Tailer(file, read_size).tail(lines)
  File "C:\Python27\lib\site-packages\tailhead\__init__.py", line 58, in __init__
    raise ValueError("io object must be in the binary mode")
ValueError: io object must be in the binary mode
gvalkov commented 8 years ago

Your conclusions are correct - it doesn't work on Windows and with Python 2. I went ahead and reverted that commit. It would have been great if tailhead just worked out of the box. I really hope to finally tackle this over the weekend.

Thanks for trying it out and for your patience.