...
This commit is contained in:
@@ -14,7 +14,7 @@ has some usefull stuff as well
|
||||
|
||||
## Installation
|
||||
|
||||
You can install `herolib` directly from the Git repository using `uv pip` (or `pip`):
|
||||
You can install `herolib` directly from the Git repository using `uv pip`:
|
||||
|
||||
```bash
|
||||
uv pip install git+https://git.ourworld.tf/herocode/herolib_python.git
|
||||
@@ -36,6 +36,10 @@ import herolib.core.loghandler.mylogging
|
||||
from herolib.core.loghandler.mylogging import MyLogger
|
||||
```
|
||||
|
||||
## how to integrate python in other projects
|
||||
|
||||
see [Python Herolib Integration](pythonsetup/README.md)
|
||||
|
||||
## Version Control
|
||||
|
||||
This library follows standard Git version control practices. Releases can be managed by tagging specific commits in the Git repository. Users installing directly from the Git URL can specify a particular branch, tag, or commit hash to get a specific version. For example:
|
||||
|
Binary file not shown.
@@ -24,7 +24,7 @@ def search(l: Logger, args_: SearchArgs) -> List[LogItem]:
|
||||
raise ValueError('category cannot be longer than 10 chars')
|
||||
|
||||
from_time = args.timestamp_from.unix() if args.timestamp_from else 0
|
||||
to_time = args.timestamp_to.unix() if args.timestamp_to else ourtime_new('2100-01-01').unix()
|
||||
to_time = args.timestamp_to.unix() + 1 if args.timestamp_to else ourtime_new('2100-01-01').unix()
|
||||
|
||||
if from_time > to_time:
|
||||
raise ValueError(f'from_time cannot be after to_time: {from_time} > {to_time}')
|
||||
@@ -62,52 +62,41 @@ def search(l: Logger, args_: SearchArgs) -> List[LogItem]:
|
||||
if len(result) >= args.maxitems:
|
||||
break
|
||||
|
||||
if not line.strip() and current_item:
|
||||
if from_time <= current_item.timestamp.unix() <= to_time:
|
||||
if (not args.cat or args.cat == current_item.cat) and \
|
||||
(not args.log or args.log.lower() in current_item.log.lower()) and \
|
||||
(args.logtype is None or args.logtype == current_item.logtype):
|
||||
result.append(current_item)
|
||||
current_item = None
|
||||
continue
|
||||
|
||||
if not line.startswith(' ') and not line.startswith('E'):
|
||||
# Helper to add current_item to result if it matches criteria
|
||||
def _add_item_if_matches():
|
||||
nonlocal current_item
|
||||
if current_item:
|
||||
if from_time <= current_item.timestamp.unix() <= to_time:
|
||||
if (not args.cat or args.cat == current_item.cat) and \
|
||||
(not args.log or args.log.lower() in current_item.log.lower()) and \
|
||||
(args.logtype is None or args.logtype == current_item.logtype):
|
||||
result.append(current_item)
|
||||
if (not args.cat or args.cat == current_item.cat) and \
|
||||
(not args.log or args.log.lower() in current_item.log.lower()) and \
|
||||
(args.logtype is None or args.logtype == current_item.logtype):
|
||||
result.append(current_item)
|
||||
current_item = None # Reset after processing
|
||||
|
||||
if not line.strip(): # Empty line, finalize previous item
|
||||
_add_item_if_matches()
|
||||
continue
|
||||
|
||||
if not line.startswith(' ') and not line.startswith('E'): # New timestamp line
|
||||
_add_item_if_matches() # Finalize previous item
|
||||
try:
|
||||
current_time = ourtime_new(f"{file_time.day()} {line.strip()}")
|
||||
current_item = None
|
||||
except ValueError:
|
||||
current_time = None
|
||||
current_item = None
|
||||
current_item = None # Reset for new item
|
||||
elif current_time:
|
||||
if line.startswith(' ') or line.startswith('E'):
|
||||
if len(line) > 14 and line[13] == '-':
|
||||
if current_item:
|
||||
if from_time <= current_item.timestamp.unix() <= to_time:
|
||||
if (not args.cat or args.cat == current_item.cat) and \
|
||||
(not args.log or args.log.lower() in current_item.log.lower()) and \
|
||||
(args.logtype is None or args.logtype == current_item.logtype):
|
||||
result.append(current_item)
|
||||
|
||||
is_error = line.startswith('E')
|
||||
logtype = LogType.ERROR if is_error else LogType.STDOUT
|
||||
cat = line[2:12].strip()
|
||||
log_content = line[15:]
|
||||
if len(line) > 14 and line[13] == '-': # New log entry line
|
||||
_add_item_if_matches() # Finalize previous item
|
||||
|
||||
is_error = line.startswith('E')
|
||||
logtype = LogType.ERROR if is_error else LogType.STDOUT
|
||||
cat = line[2:12].strip()
|
||||
log_content = line[15:]
|
||||
|
||||
current_item = LogItem(timestamp=current_time, cat=cat, log=log_content.strip(), logtype=logtype)
|
||||
elif current_item:
|
||||
current_item.log += "\n" + (line[15:] if len(line) >15 else line)
|
||||
current_item = LogItem(timestamp=current_time, cat=cat, log=log_content.strip(), logtype=logtype)
|
||||
elif current_item: # Continuation line
|
||||
current_item.log += "\n" + (line[15:] if len(line) >15 else line)
|
||||
|
||||
if current_item:
|
||||
if from_time <= current_item.timestamp.unix() <= to_time:
|
||||
if (not args.cat or args.cat == current_item.cat) and \
|
||||
(not args.log or args.log.lower() in current_item.log.lower()) and \
|
||||
(args.logtype is None or args.logtype == current_item.logtype):
|
||||
result.append(current_item)
|
||||
_add_item_if_matches() # Finalize the last item in the file
|
||||
|
||||
return result
|
Binary file not shown.
@@ -93,6 +93,7 @@ def new(time_str: str) -> OurTime:
|
||||
'%Y-%m-%d %H:%M:%S',
|
||||
'%Y-%m-%d %H:%M',
|
||||
'%Y-%m-%d %H',
|
||||
'%Y-%m-%d-%H', # Add this format for dayhour parsing
|
||||
'%Y-%m-%d',
|
||||
'%d-%m-%Y %H:%M:%S',
|
||||
'%d-%m-%Y %H:%M',
|
||||
|
Reference in New Issue
Block a user