Skip to main content

A logging package for tracing function calls with error handling and email notification

Project description

TrackLogging

TrackLogging is a logging package for tracing function calls with error handling and email notification.

Installation

You can install TrackingLog using pip:

pip install trackinglog

Github URL

https://github.com/shiyi-yinghao/trackinglog

PyPi URL

https://pypi.org/project/trackinglog/

version History

0.1.0 Package Draft created

0.1.1 Decorator get_log and directly object creator get_logger created. Added setup check decorator. Added p-functions(print and log).

0.1.2 Added error handling. Added verbose option for decorator. Added called function name.

0.1.3 Added profiler for both function level and line level. Updated error handling logic: reset verbose to False, but it will now raise error instead. Added class name to log. Added dependency pakages. Added resource performance tracking.

0.1.4 Formatted the logging message with indentation. Add print to log feature. Refactor the get_log function.

0.1.5 Added cache log cleaner.

0.1.6 Updated Log config to Parameter config. Added inline log usage.

0.1.6.2 Fix several bugs.

0.1.7 Add Error Handling message merchanism.

0.1.8 Embed Task Manager; Optimized cache log logic.

0.1.8.3 Enhanced task manager with new task param, introduced finish token.

0.1.8.4 Enhanced task manager with finish, inprogress, fail status; Add root folder path; Bug fix.

0.1.8.5 Enhanced task manager with new resume task mechanism. Now new task == True (must be new task); None (new or resume); False (resume only).

0.1.8.6 Now resume_task support True which would resume latest task. Bug fix.

0.1.9 Optimize Log logic. Bug Fix.

0.1.9.1 Set Default task name and root_folder_path. Allow usage without setup. Increase default task num limit to 500.

Feature in developing

Add public and private log

Add Added email notification.

Add Kafka message notification

Add Inherit Merchanism

Add debug suggestion message

Uaage for function and quick settings:

import logging
import trackinglog
import inspect

# Setup the LogManager with root logging path
trackinglog.logger.setup(root_task_path='./logs')

@trackinglog.logger.get_log('my_logger', verbose=1, enable_profiling="line")
def my_function(log=None):  # Notice how the log parameter is expected
    log.info("This function does something important.")
    print("Function is executing...")
    # assert False, "This function is broken!"
    
my_function()  # Running the function will log start and end, using the specific logger

Comprehensive Config with Task Management setup

trackinglog.logger.setup(task_name = "Tak1",
                         root_folder_path='./tasks',  # default ./cache/__trackinglog__
                         task_config={"task_num_limit":3, "task_expiration_date":3},
                         log_config={'root_log_path':"./logs", '_cache_log_path':"./logs/cache", 'cache_log_num_limit':10, '_cache_log_day_limit':7},
                         email_credential={'username':"PLACEHOLDER", 'password':"PLACEHOLDER",  'root_emails_folder':"./logs/emails"},
                         lock_config={"lock_folder_path":"./logs/locks"})
                         

Usage for class and comprehensive settings:

import logging
import trackinglog
import inspect

trackinglog.logger.setup(root_task_path='./logs', log_config={'root_log_path':"./logs", '_cache_log_path':"./logs/cache", 'cache_log_num_limit':10, '_cache_log_day_limit':7},
                                                    email_credential={'username':"PLACEHOLDER", 'password':"PLACEHOLDER",  'root_emails_folder':"./logs/emails"},
                                                    lock_config={"lock_folder_path":"./logs/locks"})

@trackinglog.logger.get_log('my_logger_cls', verbose=1, enable_profiling="line", print2log=True)
class testclass:
    def __init__(self, a: int):
        self.a=a
    def p(self):
        self.log.info("class log")
        # assert False , "This function is broken!"

    def count(self, n: int):
        for i in range(n):
            print(i)
    

t=testclass(2.2)
t.p()
t.count(3)

Usage inside a function:

trackinglog.logger.setup(root_task_path='./logs')

def my_function():
    log=trackinglog.logger.get_logger('my_logger_func')
    log.info("This function does something important.")
    print("Function is executed")

my_function() 

Configuration and Parameters:

trackinglog.logger.setup(root_log_path='./logs') @trackinglog.logger.get_log('my_logger_cls', verbose=1, enable_profiling="function", print2log=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trackinglog-0.1.9.1.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trackinglog-0.1.9.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file trackinglog-0.1.9.1.tar.gz.

File metadata

  • Download URL: trackinglog-0.1.9.1.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for trackinglog-0.1.9.1.tar.gz
Algorithm Hash digest
SHA256 498394445b4e70c65ce4ba628f41f832aafe1f7fc62b5ffc03af8b71ebde3d6c
MD5 bc82cc99818ff0afb45e7b74728910d7
BLAKE2b-256 21f3eb2acfdf2e48dfe377b158f84bb2aba9a2085aa5c393cfa583b9d3b67e16

See more details on using hashes here.

File details

Details for the file trackinglog-0.1.9.1-py3-none-any.whl.

File metadata

  • Download URL: trackinglog-0.1.9.1-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.6

File hashes

Hashes for trackinglog-0.1.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4650a18eb9276553289695753dde6e38a7adc71cf55989d9cff5bf9f556dc901
MD5 4816f811349e8448cb5a5bbc7295e750
BLAKE2b-256 7cb2ec3b3752365842883bbf77aca1806f8921878ddb49ad7d516e4ddb25a495

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page