ISEPOS-2280 Added base loggers scripts #1

Contributor

General Information

  • PR Type: New feature
  • Solves ticket(s): ISEPOS-2280.
  • The branch has been deployed to test.isl: no

Changes made / Cause of error / Reason for refactoring and solution

Added simple base logger scripts for matlab, octave and python.

## General Information * PR Type: **New feature** * Solves ticket(s): **ISEPOS-2280**. * The branch has been deployed to test.isl: **no** ## Changes made / Cause of error / Reason for refactoring and solution Added simple base logger scripts for matlab, octave and python. #### Related pull requests - [insilicolab](https://bitbucket.org/episodes-platform/insilicolab/pull-requests/3488/overview)
ymlesni added 1 commit 2024-09-26 11:31:55 +02:00
asia requested review from h.siejkowski 2024-09-26 13:22:42 +02:00
asia reviewed 2024-09-26 13:23:58 +02:00
asia left a comment
First-time contributor

Do we need separate scripts for Octave and Matlab? Are they different?

Do we need separate scripts for Octave and Matlab? Are they different?
asia reviewed 2024-09-26 13:32:36 +02:00
@ -0,0 +37,4 @@
% Example usage:
% logger = base_logger.getInstance();
% logger.info('This is an info message');
% logger.error('This is an error message');
First-time contributor

Can we put here an example with error object? So that the stack trace of the exception gets logged.

Can we put here an example with error object? So that the stack trace of the exception gets logged.
Author
Contributor

Base logger has been enchanced and example for error logging has been added.

Base logger has been enchanced and example for error logging has been added.
asia reviewed 2024-09-26 13:33:22 +02:00
@ -0,0 +41,4 @@
Example:
--------
logger = getDefaultLogger(__name__)
logger.info("This is an info message.")
First-time contributor

An example with an error with logging stack trace would be convenient here

An example with an error with logging stack trace would be convenient here
Author
Contributor

Example for error with stack trace logging has been added.

Example for error with stack trace logging has been added.
ymlesni added 1 commit 2024-09-30 23:47:06 +02:00
ymlesni added 1 commit 2024-09-30 23:59:53 +02:00
asia reviewed 2024-10-02 16:59:07 +02:00
@ -0,0 +45,4 @@
try:
raise Exception('Exception for example.')
except Exception as e:
logger.error('An error occurred:', exc_info=True) # Log with stack trace
First-time contributor

We have except Exception as e but the e is not used anywhere... is this correct?

We have `except Exception as e` but the `e` is not used anywhere... is this correct?
Owner

Maybe it is good to use here the logger.exception() (doc) method as a showcase.

Maybe it is good to use here the `logger.exception()` ([doc](https://docs.python.org/3/library/logging.html#logging.Logger.exception)) method as a showcase.
Author
Contributor

e could be used to process exception further, but it is not necessary for example, I will remove it.
Would adding logger.exception() as a additional option be a good idea (to still showcase how to log exception at chosen log level)? For now I will change to logger.exception().

`e` could be used to process exception further, but it is not necessary for example, I will remove it. Would adding `logger.exception()` as a additional option be a good idea (to still showcase how to log exception at chosen log level)? For now I will change to `logger.exception()`.
asia requested changes 2024-10-02 16:59:54 +02:00
Dismissed
@ -0,0 +43,4 @@
logger = getDefaultLogger(__name__)
logger.info("This is an info message.")
try:
raise Exception('Exception for example.')
First-time contributor

Maybe just put here some placeholder meaning that this is a code that may produce an error

Maybe just put here some placeholder meaning that this is a code that may produce an error
Author
Contributor

Ok, I will do the same for Matlab and Octave versions.

Ok, I will do the same for Matlab and Octave versions.
h.siejkowski approved these changes 2024-10-02 18:56:40 +02:00
ymlesni added 1 commit 2024-10-03 08:40:56 +02:00
asia requested changes 2024-10-04 17:05:47 +02:00
Dismissed
@ -0,0 +11,4 @@
Retrieves or creates a logger with the specified name and sets it up with a file handler.
The logger is configured to write log messages to the file path specified by the
'DEFAULT_LOG_PATH' environment variable. It uses the 'INFO' level as the default
First-time contributor

I think the name was changed to 'APP_LOG_FILE'

I think the name was changed to 'APP_LOG_FILE'
@ -0,0 +36,4 @@
Raises:
-------
KeyError:
If the 'DEFAULT_LOG_PATH' environment variable is not set.
First-time contributor

Here, again, the name of the variable should be updated. But I thought also that instead of throwing an error, we might use some default file name, to allow users to run the app also outside of the platform. But, I would set the default log file name to something different than "application.log", so that we know that we could notice if something is wrong with setting the environment variable.

Here, again, the name of the variable should be updated. But I thought also that instead of throwing an error, we might use some default file name, to allow users to run the app also outside of the platform. But, I would set the default log file name to something different than "application.log", so that we know that we could notice if something is wrong with setting the environment variable.
ymlesni added 2 commits 2024-10-15 11:56:33 +02:00
asia requested changes 2024-10-15 14:28:31 +02:00
Dismissed
@ -0,0 +65,4 @@
function this = base_logger()
logFileName = getenv("APP_LOG_FILE");
if isempty(logFileName)
logFileName = 'fallbackPathApplication.log';
First-time contributor

Can we use a different name? Something that we would consider a log file at first glance ('fallbackPath' is something I wouldn't) - if we don't want to make it too simple, to avoid name collision with other things, maybe e.g. base-app-log.log or base-logger-log.log or something like that

Can we use a different name? Something that we would consider a log file at first glance ('fallbackPath' is something I wouldn't) - if we don't want to make it too simple, to avoid name collision with other things, maybe e.g. base-app-log.log or base-logger-log.log or something like that
asia marked this conversation as resolved
ymlesni added 1 commit 2024-10-15 17:00:11 +02:00
asia approved these changes 2024-10-15 20:17:17 +02:00
ymlesni added 1 commit 2024-10-15 20:43:35 +02:00
mieszkomakuch merged commit d917a329e0 into main 2024-10-25 12:09:49 +02:00
Login to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: episodes-platform/shared-snippets#1
No description provided.