Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loguru for logging. #71

Merged
merged 8 commits into from
Sep 27, 2023
Merged

Loguru for logging. #71

merged 8 commits into from
Sep 27, 2023

Conversation

MikhailBurdukov
Copy link
Contributor

@MikhailBurdukov MikhailBurdukov commented Sep 25, 2023

Changed the logging module to loguru to provide process-safe logging.

@MikhailBurdukov
Copy link
Contributor Author

Should we switch to the loguru for tests/integration/ in this PR?

@MikhailBurdukov MikhailBurdukov marked this pull request as ready for review September 25, 2023 15:10
@MikhailBurdukov MikhailBurdukov requested review from aalexfvk and Alex-Burmak and removed request for aalexfvk September 25, 2023 15:10
"level": "DEBUG",
},
},
"loguru": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd propose to change the config structure.
I propose to move format definition in a separate key instead of function _handler_configuration
Like so:

"loguru" : {
  "formats": {
    "ch-backup": "{time:YYYY-MM-DD H:m:s,SSS} {process.name:11} {process.id:5} [{level:8}] {extra[logger_name]}: {message}",
  },
  "handlers": {
    "ch-backup": {
      "sink": "/var/log/ch-backup/ch-backup.log",
      "level": "DEBUG",
      "format": "ch-backup"
      # "enqueue": True  # don't define this but set all handlers in code as enqueued without option
    } 
    #...
  } 
  #...
}

"urllib3.connectionpool", "/var/log/ch-backup/boto.log", "DEBUG"
),
],
"activation": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this from config. It may be confusing what this option for.

frame = frame.f_back
depth += 1

try:
Copy link
Contributor

@aalexfvk aalexfvk Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this and put bind(logger_name=record.name) to pass original logger name to handlers

@@ -184,7 +184,7 @@ def _copy_dir(from_disk: str, from_path: str, to_disk: str, to_path: str) -> Non


def _exec(command: str, common_args: List[str], command_args: List[str]) -> List[str]:
logger = logging.getLogger("clickhouse-disks")
logger = ch_logging.getLogger("clickhouse-disks")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename ch_logging to logging ?



def _as_seconds(t: str) -> int:
return int(parse_timespan(t))


def _handler_configuration(name: str, sink: str, level: str) -> dict:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed yet ?

ch_backup/logging.py Outdated Show resolved Hide resolved
@aalexfvk
Copy link
Contributor

Should we switch to the loguru for tests/integration/ in this PR?

In this PR not.

@aalexfvk aalexfvk merged commit 5b5e6c7 into main Sep 27, 2023
11 checks passed
@aalexfvk aalexfvk deleted the MDB-24517-loguru_for_logging branch September 27, 2023 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants