Package: pythontail
PythonTail: a Unix tail implementation in python.
Version:0.9Table of ContentsGetting StartedUnix version comparisonInstallation processUsageExamplesLicenseGetting StartedUnix version comparisonUnix tail implementation list (adapted)item:default output line = 10descrtption:    default output with 10 lines for each tailed filestatus:         [OK]item:-c, --bytes=[+]NUMdescription:    output the last NUM bytes; or use -c +NUM to output startingwith byte NUM of each filestatus:         [PENDING]item:-f, --followdescription:    output appended data as the file grows;status:         [OK]item:-n, --lines=NUMdescription:    output the last NUM lines, instead of the last 10; or use -nstatus:         [OK]item:--max-unchanged-stats=Ndescription:    with --follow=name, reopen a FILE which has notchanged size after N (default 5) iterations to see if it hasbeen unlinked or renamed (this is the usual case of rotatedlog files); with inotify, this option is rarely usefulstatus:         [PENDING]item:--pid=PIDdescription:    with -f, terminate after process ID, PID diesstatus:         [PENDING]item:-q, --quiet, --silentdescription:    never output headers giving file namesstatus:         [OK]item:--retrydescription:    keep trying to open a file if it is inaccessiblestatus:         [PENDING]item:-s, --sleep-interval=Ndescription:    with -f, sleep for approximately N seconds (default 0)between iterations; at least once every N secondsstatus:         [OK]item:-v, --verbosedescription:    always output headers giving file namesstatus:         [PENDING]item:-z, --zero-terminateddescription:    line delimiter is NUL, not newlinestatus:         [PENDING]item:--helpdescription:    display this help and exitstatus:         [OK]item:--versiondescription:    output version information and exitstatus:         [OK]item:multiple files supportdescription:    tail as many files as wanted with all available parameters working as wellstatus:         [OK]Unique tail implementationsitem:usage as both terminal command and as python moduledescription:    the use of all parameters within terminal command lineand by importing as a module inside a python scriptstatus:         [OK]item:-d, --debugdescription:    create a log file and register all ocurrencies of regularbehavior information, debug and errors as the timestamp and logged userstatus:         [OK]item:--loglessdescription:    send all output to stdout with no log folder or file being createdstatus:         [OK]item:?description:    tail files over tcp/ipstatus:         [PENDING]Via BashInstallation Processinstall as a module:pipinstallpythontailand use it as:frompythontailimporttailtail.run(["dir/log/file.log"])use as terminal command:gitclonehttps://github.com/natanaelfneto/pythontail.git
pythonpythontail.py-henjoyUsagethis messagem can also be found withpython pythontail.py -hcommandusage: pythontail.py [-h] [-f | -n LINES] [-q] [-s SLEEP] [-d] [-v] sources [sources ...]

Unix tail implementation in python 

optional arguments:
-h, --help                  show this help message and exit
-f, --follow                flag to not limit number of lines tailed
-n LINES, --lines LINES     number of lines to follow in total array of sources

-q, --quiet, --silent       never output headers giving file names

-s SLEEP, --sleep SLEEP, --sleep-interval SLEEP
                            with --follow, sleep for approximately N seconds
                            (default 0) between iterations; least once every N seconds

-d, --debug                 process debug flag
-v, --version               output software versionExamplesFirst we need a fake log fileGenerate many live fake logs files by running:pythonpythontail/test/fake_log_generator.py<integer>&for the example1.py, generate the minimum of 2 fake log filesThis will create twofake_n.logfiles in~/log/fake_n.logthat can be tailedUsing it as console command for tail filespython pythontail/pythontail.py -f ~/log/fake_1.log ~/log/fake_2.logUsing it as python module for tail filesCreate a virtual env and activate it (can be pyenv or virtualenv or any other)mkvirtualenvpythontail
workonpythontailInstall pythontail modulepipinstallpythontailCreate your code as the available inpythontail/examples/example1.py\frompythontailimporttailfrompathlibimportPathimportos# get as many valid files paths you want to be tailedlog_file_1=str(Path(f"{os.path.expanduser("~")}/log/fake_1.log"))log_file_2=str(Path(f"{os.path.expanduser("~")}/log/fake_2.log"))# tail themtail.run(# debug=False,# quiet=False,# lines=10,# sleep=0,sources=[log_file_1,log_file_2])# for a --follow atribute, set the maximum number of lines to zero [lines=0]# optional --sleep atribute only works with --follow flag, done by making [lines=0]Check the output of example1 by running the script file:pythonpythontail/examples/example1.pyLicenseMIT LicenseCopyright (c) 2017 Natanael F. Neto (natanaelfneto)Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.