mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-24 18:58:33 +02:00
i3-companion: log to systemd
This commit is contained in:
parent
6a2db7ed4b
commit
6638bfdb36
1 changed files with 7 additions and 6 deletions
|
@ -5,7 +5,6 @@
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import asyncio
|
import asyncio
|
||||||
|
@ -16,8 +15,9 @@ import functools
|
||||||
|
|
||||||
from i3ipc.aio import Connection
|
from i3ipc.aio import Connection
|
||||||
from i3ipc import Event
|
from i3ipc import Event
|
||||||
|
from systemd import journal
|
||||||
|
|
||||||
logger = logging.getLogger(os.path.splitext(os.path.basename(sys.argv[0]))[0])
|
logger = logging.getLogger("i3-companion")
|
||||||
|
|
||||||
|
|
||||||
def on(*events):
|
def on(*events):
|
||||||
|
@ -395,10 +395,11 @@ if __name__ == "__main__":
|
||||||
root = logging.getLogger("")
|
root = logging.getLogger("")
|
||||||
root.setLevel(logging.WARNING)
|
root.setLevel(logging.WARNING)
|
||||||
logger.setLevel(options.debug and logging.DEBUG or logging.INFO)
|
logger.setLevel(options.debug and logging.DEBUG or logging.INFO)
|
||||||
ch = logging.StreamHandler()
|
if sys.stdin.isatty():
|
||||||
ch.setFormatter(logging.Formatter(
|
ch = logging.StreamHandler()
|
||||||
"%(levelname)s[%(name)s] %(message)s"))
|
ch.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
|
||||||
root.addHandler(ch)
|
else:
|
||||||
|
root.addHandler(journal.JournalHandler(SYSLOG_IDENTIFIER=logger.name))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
asyncio.get_event_loop().run_until_complete(main(options))
|
asyncio.get_event_loop().run_until_complete(main(options))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue