Git Product home page Git Product logo

logger's Introduction

Logger - CPP microservices

Email-Service

Features

1. Help
  usage: log.py [-h] [-component COMPONENT [COMPONENT ...]] [-cleanUp]

  Logger for Microservices based Backend Components Components.

  optional arguments:
    -h, --help            show this help message and exit
    -component COMPONENT [COMPONENT ...]
                          Specify one or more Backend components ['WebSockets', 'Subscriber', 'Diff_checker']
    -cleanUp              Remove the changes in all the CPP filess [Requires '-component' argument].
2. Enabling logs

Process CPP files inside mentioned component directory

$ ./log.py -component Diff_Checker Subscriber
Components to process:  {'Diff_Checker', 'Subscriber'}

Processing Component:  Diff_Checker

Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>

Processing Component:  Subscriber

Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
.
.
.
3. Disable logs

Remove the added code responsible for logging from CPP files

$ ./log.py -component Diff_Checker Subscriber -cleanUp
==============================================================
Clean Up in Progress!!!!!
==============================================================
Components to process:  {'Diff_Checker', 'Subscriber'}

Processing Component:  Diff_Checker

Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>

Processing Component:  Subscriber

Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
Processing CPP file: <absolute path to CPP file on the path>
.
.
.
4. Build the code

Build C++ code after enabling and disabling logging to reflect changes.

  g++ -o output_filename file1.cpp file2.cpp file3.cpp

Algorithm

  • Step 1: Update the code-base with absolute path for each component in the MAP at the top of python file.
  • Step 2: Update the binaries with absolute path for each component in the MAP at the top of python file.
  • Step 3: The information hard-coded above will be used to figure out the list of files responsible for each component and for building an abstract syntax tree for parsing C++ file.
  • Step 4: We write a boilerplate code at the top of each CPP file for a particular component, which is responsible in printing logs for each function inside CPP file.
  • Step 5: We traverse down the Abstract syntax tree of each CPP file and place a LOG_FUNCTION(); command at the start of each function in CPP file.
  • Step 6: C++ Parsing is a hard problem in itself, therefore our parser might add some extra LOG_FUNCTION(); but the accurancy for our parser is around 99.1%.
  • Step 7: After placing the boilerplate code and LOG_FUNCTION(); at the start of each function, we are ready to build the code and log information about functions in each of the mentioned component.

What are we logging ?

  1. [Current Time] Entering/Exiting function: in File: at Line: | (Number of times this function is executed as part of some operation run)

  2. [Current Time] Elapsed Time: (In seconds)

  • Current Time: Local time with microseconds precision.
  • Entering / Exiting Function: Provides information about the set of functions executed as part of user operations.
  • Name of the function: Coming up from LOG_FUNCTION(); added at the start of each function in a CPP file.
  • Absolute path of CPP file: Responsible for business logic for a particular compenent.
  • Number of times this function is executed: Helpful in resolving the performance and figuring out, if same function is executed multiple times as part of single user operation.
  • Elapsed Time: Time taken by each function for its execution.

logger's People

Contributors

suva007 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.