summaryrefslogtreecommitdiffstats
path: root/ogclient
Commit message (Collapse)AuthorAgeFilesLines
* src: log backtrace in unhandled error casesAlejandro Sirgo Rica2024-04-031-2/+2
| | | | | | | | | | | | | | | | | | | Log an error message in known error cases and log a backtrace otherwise. Define a new error type OgError to be used in all the 'raise' blocks to define the error message to log. The exception propagates until it reaches send_internal_server_error() where the exception type is checked. If the type is OgError we log the exception message. Logs the backtrace for other types. The initial error implementation printed a backtrace everytime an error ocurred. The next iteration changed it to only print a backtrace in a very particular case but ended up omiting too much information such as syntax errors or unknown error context. The actual implementation only logs the cases we already cover in the codebase and logs a bracktrace in the others, enabling a better debugging experience.
* ogclient: consolidate logging in client coreAlejandro Sirgo Rica2024-03-211-3/+6
| | | | | | | | | The main function must be able to handle the login of critical error in the main ogClient class instance. Add a try except block to the ogCLient run logic and move the relevant error logs into the except block. Delegate the error messages to the exception message. This is the first step towards error message deduplication.
* src: improve loggingJose M. Guisado2022-06-081-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* #1068 add -c/--config optional parameterJose M. Guisado2022-02-011-1/+6
| | | | | | | | | 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.
* #1065 Init config_path according to platformJose M. Guisado2021-12-101-1/+7
| | | | | | | | | | Commit 2dbcd18c06dd breaks interfaceAdm path for live operations. Keep OG_PATH to the value prior to commit 2dbcd18c06dd. 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.
* #1065 Add event subcommand argumentsJose M. Guisado2021-11-301-0/+30
| | | | | | | | | | | | | | | | | | 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]
* #1065 revisit config_path initializationJose M. Guisado2021-11-181-1/+1
| | | | | | | 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.
* #1065 Use logging module instead of syslogJose M. Guisado2021-11-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* #1065 Avoid SIGPIPE errors in windows modeJose M. Guisado2021-11-171-2/+10
| | | | | | | | | | 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.
* ogClient is AGPLv3+OpenGnSys Support Team2021-05-141-3/+3
| | | | Update license header in files.
* rename main.py to ogclientOpenGnSys Support Team2020-06-261-0/+36