Commit Graph

9 Commits (cb0bd3d194ddd4ecaab8e671444f1bf7abc8f908)

Author SHA1 Message Date
Jose M. Guisado 30fdcceea3 src: improve logging
Adds new logging handler redirecting messages to the log file
located in the Samba shared directory (applies to live mode
clients, i.e: ogLive)

Parses log level configuration from ogclient.json. See:

{
	"opengnsys": {
		...
                "log": "INFO",
		...
	}
	...
}

Adds --debug option to set root logger level to DEBUG when starting
ogClient. Overrides log level from config file.

In addition:

- Replaces any occurence of print with a corresponding logging function.
- Unsets log level for handlers, use root logger level instead.
- Default level for root logger is INFO.
- Replaces level from response log messages to debug (ogRest)
2022-06-08 10:27:06 +02:00
Jose M. Guisado ecd735c9dc #1068 add -c/--config optional parameter
ogClient allows the user to specify the json config path with optional
parameters -c / --config:

	ogclient -c /foo/bar/foobar.json

If specified config file is malformed ogClient will fail to start.
2022-02-01 09:44:42 +01:00
Jose M. Guisado 1601ad9b29 #1065 Init config_path according to platform
Commit 2dbcd18c06 breaks interfaceAdm path for live operations.

Keep OG_PATH to the value prior to commit 2dbcd18c06.

Check platform before reading config file. If platform is different
from linux then look for cfg/ogclient.json in current folder and
do not use OG_PATH.
2021-12-10 10:03:12 +01:00
Jose M. Guisado 05f2fd43c2 #1065 Add event subcommand arguments
ogClient can be invoked with additional arguments to send
event datagrams to the default event datagram socket at
127.0.0.1 port 55885.

ogclient session events invokation syntax:

	ogclient event login foobar
	ogclient event logout foobar

If event commands arguments are detected, ogclient sends the
datagram and closes afterwards.

Datagram syntax for session event is:

	session [start | stop] [user]
2021-11-30 12:44:52 +01:00
Jose M. Guisado 2dbcd18c06 #1065 revisit config_path initialization
If current platform is Linux (either live, virtual or linux) expect
/opt/opengnsys/ogclient/cfg/ to contain ogclient.json.

If current platform is not Linux then we fallback to current directory.
2021-11-18 16:31:36 +01:00
Jose M. Guisado 3dfe54968b #1065 Use logging module instead of syslog
We can't use syslog if we want to execute ogClient in the Windows
platform.

Use the native logging library so we can attach different handlers
depending on the mode ogClient is executing.

Logging configuration is done via a python dict. There is a different
dict for linux and windows. These dicts define the configuration of the
root logger, handlers and formatters used.

As of now, it is only expected to use the root logger for everything
logging related. The root logger is obtained via:

	LOGGER = logging.getLogger()

More info about handlers, formatters and loggers:
	https://docs.python.org/3/howto/logging.html

Logging configuration is done at startup, just after parsing the json
(knowing ogclient mode). If json parsing goes bad, ogclient will only
print a message to stdout.
2021-11-18 10:29:46 +01:00
Jose M. Guisado fd1f01d76b #1065 Avoid SIGPIPE errors in windows mode
SIGPIPE is only available on Unix. Add try/except so that this
import does not crash ogclient when running in Windows mode.

Only assign SIG_DFL handler to SIGPIPE when mode is not windows.

Prefer signal.signal over signal alone to better distinguish module from
function.
2021-11-17 13:00:33 +01:00
OpenGnSys Support Team cb9edc8d95 ogClient is AGPLv3+
Update license header in files.
2021-05-14 00:19:28 +02:00
OpenGnSys Support Team 0ada33c695 rename main.py to ogclient 2020-06-26 11:04:32 +02:00