Code Monkey home page Code Monkey logo

smart_tracer's Introduction

Hex.pm Version

SmartTracer

A simple tracer with recording capabilities that would help you in a live debugging session.

Installation

To use SmartTracer, update the mix.exs to include it on your dependencies.

def deps do
  [
    {:smart_tracer, "~> 0.2.0"}
  ]
end

Documentation can be viewed here: https://hexdocs.pm/smart_tracer.

Usage

When connected to a live remote console, issue the trace/2 passing the function reference and rate limit.

Tracing a global function

    iex> SmartTracer.trace(&FakeModule.hello/1, 5)
    1
    iex> FakeModule.hello("Vince")
    Elixir.SmartTracer.Support.FakeModule.hello/1 is being called with:
      ["Vince"]

Tracing a local function

    iex> SmartTracer.trace(&FakeModule.get_name/1, 5, scope: :local)
    1
    iex> FakeModule.hello("Vince")
    Elixir.SmartTracer.Support.FakeModule.get_name/1 is being called with:
      ["Vince"]

Tracing a function and getting it's return value (possible also for local tracing)

    iex> SmartTracer.trace(&FakeModulne.hello/1, 5, return: true)
    1
    iex> FakeModule.hello("Vince")
    Elixir.SmartTracer.Support.FakeModule.hello/1 is being called with:
      ["Vince"]
    Elixir.SmartTracer.Support.FakeModule.hello/1 returns:
      "Hello, my name is NAME-Vince"

Tracing a function and recording calls and returns

    iex> SmartTracer.trace(&FakeModulne.hello/1, 5, return: true, record: true)
    1

To playback all the recordings, use playback/0

    iex> SmartTracer.playback()
    [%SmartTracer.Utils.Recorder.Call{
      args: ["Vince"],
      arity: 1,
      datetime: #DateTime<2020-02-01 18:13:04Z>,
      function: :hello,
      module: SmartTracer.Support.FakeModule,
      type: :call
    },
    %SmartTracer.Utils.Recorder.Return{
      arity: 1,
      datetime: #DateTime<2020-02-01 18:13:04Z>,
      function: :hello,
      module: SmartTracer.Support.FakeModule,
      return_value: "Hello, my name is NAME-Vince",
      type: :return
    }]

smart_tracer's People

Contributors

vinceurag 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.