-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from PabloLec/dev
Update 0.0.2
- Loading branch information
Showing
5 changed files
with
286 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
__pycache__ | ||
__pycache__/ | ||
poetry.lock | ||
dev.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .logger import Logger | ||
from livelog.logger import Logger, LoggerSingleton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,57 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from sys import argv | ||
from os import _exit | ||
from .reader import start_reader | ||
from platform import system | ||
from tempfile import gettempdir | ||
from pathlib import Path | ||
from argparse import ArgumentParser | ||
from livelog.reader import start_reader | ||
|
||
if __name__ == "__main__": | ||
if len(argv) == 1: | ||
print("! No file specified !") | ||
_exit(1) | ||
|
||
start_reader(file=argv[1]) | ||
def _parse_args(): | ||
"""Parse CLI arguments. | ||
Returns: | ||
tuple: Provided arguments | ||
""" | ||
|
||
parser = ArgumentParser(description="Live read a log file") | ||
parser.add_argument( | ||
"-f", | ||
"--file", | ||
action="store", | ||
type=str, | ||
required=False, | ||
help="Log file to be read", | ||
) | ||
parser.add_argument( | ||
"-l", | ||
"--level", | ||
action="store", | ||
type=str, | ||
default="DEBUG", | ||
required=False, | ||
help="Minimum log level. Default: DEBUG", | ||
) | ||
parser.add_argument( | ||
"--nocolors", | ||
action="store_true", | ||
required=False, | ||
help="Do not color lines", | ||
) | ||
args = parser.parse_args() | ||
|
||
if args.file is not None: | ||
file = Path(args.file) | ||
else: | ||
file = ( | ||
Path("/tmp/livelog.log") | ||
if system() == "Darwin" | ||
else Path(gettempdir()) / "livelog.log" | ||
) | ||
|
||
return file, args.level, args.nocolors | ||
|
||
|
||
if __name__ == "__main__": | ||
file, level, nocolors = _parse_args() | ||
start_reader(file=file, level=level, nocolors=nocolors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.