Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Logging Module for GS #277

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open

Conversation

nameerahr
Copy link

Purpose

Setup up logging so it can be done uniformly throughout the system.
https://www.notion.so/uworbital/Implement-system-wide-logging-2327c75823fb40d7b2121eafc7001993?pvs=4

New Changes

  • Implemented logging modules in gs and obc_gs_interface.

Testing

  • Tested macros in a temporary local file.

Outstanding Changes

Copy link

Pull reviewers stats

Stats of the last 120 days for UWOrbital:

User Total reviews Time to review Total comments
Navtajh04 30 3d 6h 6m 188
dgobalak 25 2d 5h 25m 164
Yarik-Popov 6 1d 2h 22m 52
Gjjjiang 3 4d 13h 9m 13
manumanuk 2 2d 19h 49m 1
twilkhoo 1 4m 0
JoelManYunLee 1 17h 57m 4

Copy link
Contributor

@Yarik-Popov Yarik-Popov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a reason why the logger should be under common. I would move it out to a separate directory instead of it being under common

@nameerahr nameerahr requested a review from Yarik-Popov March 2, 2024 17:10
Copy link
Contributor

@Yarik-Popov Yarik-Popov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good, just some minor changes

interfaces/obc_gs_interface/logger/obc_gs_logger.c Outdated Show resolved Hide resolved
gs/logger/gs_logger.c Outdated Show resolved Hide resolved
interfaces/obc_gs_interface/logger/obc_gs_logger.c Outdated Show resolved Hide resolved
@nameerahr nameerahr requested a review from Yarik-Popov March 3, 2024 03:52
gs/logger/gs_logger.h Outdated Show resolved Hide resolved
interfaces/obc_gs_interface/logger/obc_gs_logger.h Outdated Show resolved Hide resolved
gs/logger/gs_logger.c Outdated Show resolved Hide resolved
gs/logger/gs_logger.c Outdated Show resolved Hide resolved
interfaces/obc_gs_interface/logger/obc_gs_logger.c Outdated Show resolved Hide resolved
interfaces/obc_gs_interface/logger/obc_gs_logger.c Outdated Show resolved Hide resolved
interfaces/obc_gs_interface/logger/obc_gs_logger.h Outdated Show resolved Hide resolved
@Yarik-Popov
Copy link
Contributor

Also, add *.log to the .gitignore file

@Yarik-Popov
Copy link
Contributor

Tried to log an obc_gs error code using the obc_gs_logger.h and it doesn't work. Instead of sending it to a file as your code indicates it, prints it out. I looked at the reference and it uses logMsg in gs_logger.c not obc_gs_logger.c

Copy link
Contributor

@Yarik-Popov Yarik-Popov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your implementation still doesn't work. I'm not getting any errors but when I tried returning if error code for obc_gs_error it would print to the gs_log.log instead of obc_gs_log.log

For each of your logging functions, declare at most 1 returnCode, set the type when declaring it, and then set the errCode before returning. This is to minimize the stack size

Also, add "logger.h" to gs/main.c

interfaces/logging/logger.h Outdated Show resolved Hide resolved
interfaces/logging/logger.h Outdated Show resolved Hide resolved
interfaces/obc_gs_interface/logger/obc_gs_logger.c Outdated Show resolved Hide resolved
gs/logger/gs_logger.c Outdated Show resolved Hide resolved
interfaces/obc_gs_interface/logger/obc_gs_logger.c Outdated Show resolved Hide resolved
gs/logger/gs_logger.c Outdated Show resolved Hide resolved
gs/logger/gs_logger.c Outdated Show resolved Hide resolved
interfaces/obc_gs_interface/logger/obc_gs_logger.c Outdated Show resolved Hide resolved
interfaces/obc_gs_interface/logger/obc_gs_logger.c Outdated Show resolved Hide resolved
interfaces/obc_gs_interface/logger/obc_gs_logger.c Outdated Show resolved Hide resolved
interfaces/logging/logger.h Outdated Show resolved Hide resolved
interfaces/logging/logger.h Outdated Show resolved Hide resolved
interfaces/logging/logger.h Outdated Show resolved Hide resolved
@Yarik-Popov
Copy link
Contributor

Can u try and see if you can return obc_error_code_t and gs_error_code_t directly inside of obc and gs logger respectively. If u can't, lgtm just got to test it.

@nameerahr
Copy link
Author

nameerahr commented Mar 20, 2024

Can u try and see if you can return obc_error_code_t and gs_error_code_t directly inside of obc and gs logger respectively. If u can't, lgtm just got to test it.

@Yarik-Popov do you mean to try to return those error codes without changing the general logger_error_code_t return type? That does't work.

@Yarik-Popov
Copy link
Contributor

Can u try and see if you can return obc_error_code_t and gs_error_code_t directly inside of obc and gs logger respectively. If u can't, lgtm just got to test it.

@Yarik-Popov do you mean to try to return those error codes without changing the general logger_error_code_t return type? That does't work.

Yeah. I was suspecting it not to work but still wanted u to try it as this is how I understood what Navtaj said about returning the error codes for each case

Copy link
Contributor

@Yarik-Popov Yarik-Popov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make ints be of specific size and signedness when applicable. Ill test this pr at the work session today

gs/logger/gs_logger.c Outdated Show resolved Hide resolved
gs/logger/gs_logger.c Outdated Show resolved Hide resolved
typedef enum {
OBC_ERROR_CODE,
GS_ERROR_CODE,
} logger_error_type_t;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this is needed?


// Define a general structure to hold the logger error code and its type
typedef struct {
logger_error_type_t type;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logger_error_type_t enum and logger_error_code_t struct were added because we wanted to have a general header file for functions like logErrorCode() that are used by both OBC and GS. We needed a general error code that these functions could return

Copy link
Contributor

@Yarik-Popov Yarik-Popov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes that should be quick to do. Also, this should be the last set of changes unless if the logging doesn't work properly on obc. gs logging works which is a good sign.

Comment on lines +50 to +55
#define LOG_TRACE_FROM_ISR(msg) logMsgFromISR(LOG_TRACE, __FILE__, __LINE__, msg)
#define LOG_DEBUG_FROM_ISR(msg) logMsgFromISR(LOG_DEBUG, __FILE__, __LINE__, msg)
#define LOG_INFO_FROM_ISR(msg) logMsgFromISR(LOG_INFO, __FILE__, __LINE__, msg)
#define LOG_WARN_FROM_ISR(msg) logMsgFromISR(LOG_WARN, __FILE__, __LINE__, msg)
#define LOG_ERROR_FROM_ISR(msg) logMsgFromISR(LOG_ERROR, __FILE__, __LINE__, msg)
#define LOG_FATAL_FROM_ISR(msg) logMsgFromISR(LOG_FATAL, __FILE__, __LINE__, msg)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to obc logging header file as gs doesn't have ISR logging

Comment on lines +113 to +135
/**
* @brief Log an error code from ISR
*
* @param msgLevel Level of the message
* @param file File of message
* @param line Line of message
* @param errCode The error code that needs to be logged
* @return logger_error_code_t with success code if log is successful.
*
*/
logger_error_code_t logErrorCodeFromISR(log_level_t msgLevel, const char *file, uint32_t line, uint32_t errCode);

/**
* @brief Log a message from ISR
*
* @param msgLevel Level of the message
* @param file File of message
* @param line Line of message
* @param msg The message that should be logged (MUST BE STATIC)
* @return logger_error_code_t with success code if log is successful.
*
*/
logger_error_code_t logMsgFromISR(log_level_t msgLevel, const char *file, uint32_t line, const char *msg);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to obc logging header file as gs doesn't have ISR logging

gs/logger/gs_logger.c Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants