The
fruafr.logpackage contains basic Python 3 logging utilities (CLI)
It provides :
- a CLI to log messages to the console : logtoconsole.py
- a CLI to log messages to a file: logtofile.py
- a CLI to log messages via syslog (via UDP or TCP): logtosyslog.py
It also provides :
- a tiny UDP/TCP syslog server capable of saving incoming messages to a file: tinysyslogserver.py.
- formatter.LoggerClass, a class expanding the standard logging.logger : /lib/logger.py
- formatter.FormatterClass, a class expanding the standard logging.formatter : /lib/formatter.py
To use the CLI:
pip install fruafr.log
To use the tiny syslog server, you will need to install the package with sudo permissions:
sudo pip install fruafr.log
Invoke the help command of each CLI with the -h or --help option.
e.g. logtofile.py --help
- The code has been tested on a standalone Ubuntu 22.04 LTS machine and in an Ubuntu WSL2 virtual machine.
- Python 3 only (Tested on Python 3.10).
- Requires the Python standard library and YAML.
- The documentation of the CLI is available with the
-hor-helpflags. - It accepts the standard LogRecord attributes.
- It accepts the logging levels of the standard library
- It accept the default templating style of the logging library with the
--formatoption:%(asctime)s - It provides standard and some non-standard options with the
--optionsoption to meet regular logging use cases: app, user, host, ip, interface, clientlevel, service. You have to provide the values with option flags to the CLI. These records will be added to the log message in the order specified with --options (e.g.ip,message). You can provide a custom separator for this message section with the--optsepoption.
- Should only be used for testing purposes.
- It was developed to test logtosyslog.py.
- The server can listen on a single port to both UDP (
--udpflag) and TCP (--tcpflag) sockets. It uses two processes (one for UDP and one for TCP).
Unit tests are available for all modules. It uses the Python unittest suite.
In addition, the UDP/TCP syslog client/server integration has been tested with an integration test found in tests/integration/fruafr_log_syslog_client_server.py.
Github Issues' page of the repository
- MIT licensed.
- In short : You are free to incorporate the library and/or its CLI in your open-source or proprietary projects.
- Do whatever you want with this library as long as you include the license notice and the copyright in the copies.
This project has been set up using PyScaffold 4.4. For details and usage information on PyScaffold see https://pyscaffold.org/.
