Package: anastasia-logging
Anastasia LoggingThis repository holds a logging implementation wrapper for python scripts with standarized code notifications and additional features.SummaryAboutloggingpython libraryEnhancements and additional functionalitiesLog Output StandarizationPredefined Parameters for AnastasiaLoggers from Environment VariablesCode Tags StandarizationPrint FunctionalityVersioning1. AboutloggingPython LibraryThis repository is based in python base log management library calledlogging.Commonly, when this library is intended to be used, for a basic usage a simple logging import is recommended to be used in order to avoid additional settings in our internal scripts.import logging

logging.warning("I am a very usefull warning")

OUTPUT => WARNING:root:I am a very usefull warningBut, for more complex repositories, is recommended to manage different loggers according to their necessities. For a customized logging behaviour, a Logger class must be declared from logging.import logging

logger = logging.Logger("custom_logger")
logger.warning("I am a very usefull warning")

OUTPUT => I am a very usefull warningHave you noticed in the first import logging example that appears the wordrootin the output console? This is because when you useimport loggingdirectly, a default Logger class is instanciated with namerootalong with default configurations.This repository contains a class calledAnastasiaLogger, which inherits from Logger class and standarize logging definitions and has some improvments over debugging (.debug()), information (.info()), warning (.warning()), error (.error()), critical (.critical()) and fatal (.fatal()) methods.from anastasia_logging import AnastasiaLogger

logger = AnastasiaLogger()
logger.warning("I am a very usefull warning")

OUTPUT => 2023-05-08 10:39:17 UTC/GMT-0400 | [ANASTASIA-JOB] WARNING: I am a very usefull warningIf a script already has a logging usage, it is possible to replaceimport loggingwithimport anastasia_logging as loggingand no modifications are required from the script side to work!import anastasia_logging as logging

logging.warning("I am a very usefull warning")

OUTPUT => 2023-05-08 10:39:17 UTC/GMT-0400 | [ANASTASIA-JOB] WARNING: I am a very usefull warning2. Enhancements and Additional Functionalities2.1 Log Output StandarizationAnastasiaLogger has a common structure in order to show information, which is the following one:YYYY-MM-DD HR:MN:SS UTC/GMT(+-)HHMN | [TAG] LEVEL: messageTAG is define by default as ANASTASIA-JOB (can be changed during class instantiation), and LEVEL is defined according to level method called.TAG is intended to differentiate responsabilities along scripts in other repositories.2.2 Predefined Parameters for AnastasiaLoggers from Environment VariablesFor a faster logging behaviour along an entire repository, some variables that AnastasiaLogger can recieve can be predefined as environment variables, which are:ANASTASIA_LOG_NAME: name identification of logger instance (default="anastasia-log")ANASTASIA_LOG_TAG: tag identification for job type for StreamHandlers (console) and FileHandlers (file) (default="ANASTASIA-JOB")ANASTASIA_LOG_LEVEL: define severity hierarchy for log generation (default="INFO")ANASTASIA_LOG_SAVELOG: generate.logfile containing logs generated (default="0"(deactivated))ANASTASIA_LOG_PATH: define a custom name for log file (default="anastasia-log.log")If it is not the case, AnastasiaLogger will instanciate with default parameters.2.3 Code Tags StandarizationIn order to have a common identification for upper level implementations, AnastasiaLogger holds a standarized code implementations according to different topics.The coding structure is the following one:CodeTopic0Unindentified1XXData related2XXMathematical related3XXAI related4XXResources related5XXOperative System related6XXAPI related7XXAWS relatedMethodsdebug(),info(),warning(),error(),critical()andfatal()can be declared with a code as parameter in order to extended log with a code description.import anastasia_logging as logging

logging.warning("I am a dataset warning", 100)

OUTPUT => 2023-05-08 11:55:27 UTC/GMT-0400 | [ANASTASIA-JOB] WARNING: <W100> I am a dataset warningIf a code is already predefined and no message is introduced, a default message will appear according to code declared.2.4 Print FunctionalityFor a easy visualization in console without interacting with an AnastasiaLogger, you can useprintlike a python built-in print call.import anastasia_logging as logging

logging.print("Some prints to show")

OUTPUT => 2023-05-08 11:55:27 UTC/GMT-0400 | [ANASTASIA-JOB] PRINT: Some prints to show3. Versioningv1.3.4Fixes:Fixed edge cases inANASTASIA_LOG_LEVELandANASTASIA_LOG_PATHassiganation valuesv1.3.3Fixes:Fixed edge case ofANASTASIA_LOG_SAVELOGenvironment variable detection if value entered is not a digitv1.3.2Fixes:Fixed parameter assignation forANASTASIA_LOG_SAVELOGenvironment variablev1.3.1Fixes:Default unindentifieddebug,criticalandfatalstandard codes fixedv1.3.0Features:Functionscritical,fatalanddebugincorporatedv1.2.0Features:FunctionprintincorporatedFunctionsinfo,warning,errorandprintcan return the formatted message for further usagev1.1.1Fixes:FunctionbasicConfigwas skipping predefined structures with tags and log streamhandlersv1.1.0Features:FunctionbasicConfigequivalent from logging implemented for root AnastasiaLoggerv1.0.0Features:AnastasiaLoggerClass abstractionStandar code description definitions forINFO,WARNINGandERRORPredefinedAnastasiaLoggerparameters loaded from environment variables