summaryrefslogtreecommitdiffstats
path: root/src/log.py
Commit message (Collapse)AuthorAgeFilesLines
* src: log backtrace in unhandled error casesAlejandro Sirgo Rica2024-04-031-1/+5
| | | | | | | | | | | | | | | | | | | 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.
* src: make exception messages more contextual and explicitAlejandro Sirgo Rica2024-03-211-1/+1
| | | | | | | Provide more information in exception messages as those are the source of the logging messages. Add information about paths, files or configuration related to the operation associated to the exception.
* src: add missing copyright noticesv1.2.8Jose M. Guisado2023-04-181-0/+8
|
* log: add file handler for ogLive "real time log"Jose M. Guisado2022-12-051-0/+9
| | | | | | | | | | | Clients running in ogLive can show log messages via a lighttp server. Particularly, a html page named "real time log" consists of <text-area> tags with the contents of two particular text files /tmp/session.log and /tmp/command.log Adds a Python logging handler in order to write ogClient log messages into /tmp/session.log. This way ogClient logs are show in the "real time log" html page too.
* log: declare samba handler only in live modeJavier Sánchez Parra2022-11-021-9/+20
| | | | | | ogClient in linux mode only write its logs to syslog and the console. Also, raise exception if mode its not supported.
* log: import fcntl only on linuxJavier Sánchez Parra2022-11-021-67/+73
| | | | | Otherwise, ogClient do not work on Windows because fcntl module do not exists on Windows.
* src: improve loggingJose M. Guisado2022-06-081-7/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* #1065 Use logging module instead of syslogJose M. Guisado2021-11-181-0/+72
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.