-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* closes CERNDocumentServer/cds-rdm#376
- Loading branch information
Showing
8 changed files
with
130 additions
and
6 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2025 CERN. | ||
# | ||
# Invenio-Jobs is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Loggigng module for jobs.""" | ||
|
||
from .backends import SearchJobLogBackend | ||
from .builders import JobLogBuilder | ||
|
||
__all__ = ( | ||
"SearchJobLogBackend", | ||
"JobLogBuilder", | ||
) |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2025 CERN. | ||
# | ||
# Invenio-Jobs is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Loggigng module for jobs.""" | ||
|
||
from invenio_logging.datastreams.backends import SearchBackend | ||
|
||
|
||
class SearchJobLogBackend(SearchBackend): | ||
"""Backend for storing job logs in datastreams.""" | ||
|
||
def __init__(self): | ||
"""Initialize backend for job logs.""" | ||
super().__init__(log_type="job") |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2025 CERN. | ||
# | ||
# Invenio-Jobs is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Loggigng module for jobs.""" | ||
|
||
from invenio_logging.datastreams.builders import LogBuilder | ||
|
||
from .backends import SearchJobLogBackend | ||
|
||
|
||
class JobLogBuilder(LogBuilder): | ||
"""Builder for structured job logs.""" | ||
|
||
type = "job" | ||
|
||
backend_cls = SearchJobLogBackend | ||
|
||
@classmethod | ||
def build(cls, log_event): | ||
"""Build an job log event context.""" | ||
return cls.validate(log_event) | ||
|
||
@classmethod | ||
def send(cls, log_event): | ||
"""Send log event using the backend.""" | ||
cls.backend_cls().send(log_event) | ||
|
||
@classmethod | ||
def search(cls, query): | ||
"""Search logs.""" | ||
results = cls.backend_cls().search(query) | ||
return cls.schema.load(results, many=True) |
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
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
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
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
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