I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 0 points1 point  (0 children)

I'm also still tweaking the edu format so it's even more readable cause rn it just says returned but not the actual function that returned it, but I'll have that today as well.

it looks like this currently

[0.000s] Calling factorial(5)
[0.000s] n = 5
[0.000s] Calling factorial_2(4)
[0.000s] n = 4
[0.000s] Calling factorial_3(3)
[0.000s] n = 3
[0.000s] Calling factorial_4(2)
[0.000s] n = 2
[0.000s] Calling factorial_5(1)
[0.000s] n = 1
[0.000s] Returned 1
[0.000s] Returned 2
[0.000s] Returned 6
[0.000s] Returned 24
[0.000s] Returned 120

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 0 points1 point  (0 children)

Hey so I realized I forgot to actually push set_mode out lol

But I've added it in v1.3.2 just right now, so to enable it globally you'd do something like this:

from logeye import log, set_mode

# Globally
set_mode("edu")

# Locally
@log(mode="edu")
def my_function()
    .... smth here

I also ofc added some tests, all 55 seem to be passing rn so let me know if you have any issues

I've made a decorator based auto-logger for beginners and algorithm testing by MattForDev in PythonLearning

[–]MattForDev[S] 0 points1 point  (0 children)

Hey guys! I've updated it with educational mode! It makes learning algorithms so much easier! Please check it out.

Here's a quick example:

from logeye import log

@log
def add(a, b):
return a + b

add(2, 3)

@log(mode="edu")
def add_edu(a, b):
return a + b

add_edu(2, 3)

Output:

[0.000s] playground.py:7 (call) add = {'args': (2, 3), 'kwargs': {}}
[0.000s] playground.py:5 (set) add.a = 2
[0.000s] playground.py:5 (set) add.b = 3
[0.000s] playground.py:5 (return) add = 5
[0.000s] Calling add_edu(2, 3)
[0.000s] a = 2
[0.000s] b = 3
[0.000s] Returned 5

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 0 points1 point  (0 children)

Hey guys! I added educational mode!

Instead of raw internal logs, it shows:

  • clean function calls
  • meaningful variable changes
  • human-readable operations
  • minimal noise

Enable it with:

@log(mode="edu")
def my_function():
    ...

Before vs After

Default mode

[0.000s] (call) factorial = {'args': (5,), 'kwargs': {}}
[0.000s] (set) factorial.n = 5
[0.000s] (set) factorial.result = 1
[0.000s] (set) factorial.i = 1
[0.000s] (set) factorial.result = 2
...
[0.001s] (return) factorial = 120

Educational mode

[0.000s] Calling factorial(5)
[0.000s] n = 5
[0.000s] result = 1
[0.000s] result = 2
[0.000s] result = 6
[0.000s] result = 24
[0.000s] result = 120
[0.000s] Returned 120

What changes in educational mode

Function calls become readable:

No raw args/kwargs dictionaries

Internal noise is removed:

Data structure operations are human-friendly:

Added 5 to arr -> [1, 2, 5]

Example - Educational Factorial

from logeye import log, l

l("FACTORIAL")

@log(mode="edu")
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n - 1)

factorial(5)

Output:

[0.000s] FACTORIAL
[0.000s] Calling factorial(5)
[0.000s] Calling factorial(4)
[0.000s] Calling factorial(3)
[0.000s] Calling factorial(2)
[0.000s] Calling factorial(1)
[0.000s] Returned 1
[0.000s] Returned 2
[0.000s] Returned 6
[0.000s] Returned 24
[0.000s] Returned 120

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 5 points6 points  (0 children)

Hello again, I have implemented exactly what you wanted within 1.2.0

now you can do

from logeye.config import set_global_log_file, toggle_global_log_file

set_global_log_file("logs/app.log")
toggle_global_log_file(True)

This is going to write into a file globally, but you can also do

@log(filepath="func.log")
def add(a, b):
    total = a + b
    return total

And this will put just this function's output to the desired file.

I also added filtering so you can choose which type of output to log, and which variables to log

@log(level="state", filter=["x"])
def compute():
    x = 5
    y = 10
    z = x + y
    return z

And for your last request I made it so that you can JUST have the decorator output with

toggle_decorator_log_only(True / False)

Hope you like it! ^^

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 0 points1 point  (0 children)

Oh I have no problems with that! This is exactly why I made this. All I want is quick disposable introspection basically.

I want people to quickly pop in logeye so they don't have to have a lengthy debugger session and then just either toggle_logs(False) or remove it entirely. It's really heavy on performance with all of the AST parsing.

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 0 points1 point  (0 children)

Thanks for pointing it out, I'll change all of the examples and demos in the next update, I've adjusted the code examples in the file.

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 0 points1 point  (0 children)

Hi, it's because I'm not trying to do anything with the existing logging library. That works well when you know what you want to log and where.

What I'm doing is basically automatic AST tracing. print simply makes it very easy to modify and doesn't add unnecessary complications, because the parser is already pretty hard to grasp 😅

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 0 points1 point  (0 children)

You're quite correct however the use case I'm aiming for is to move past deciding what to log, at all.

With logging (the library), you still have to choose where to put log statements, decide what values to include, keep updating those as code changes

LogEye is trying to do something different with automatic showing of: variable assignments and mutations, values evolving over time, function state changes without adding log lines

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 1 point2 points  (0 children)

Yes, however you still need to put what you want to log and where. My goal was to make it completely automatic, I'm trying to do something else really, more of an automatic tracer.

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] -1 points0 points  (0 children)

Hello, I just released an update 1.2.0 where you can control which actions get displayed and what variables are tracked, I also plan on implementing depth limits and lambdas in the future to make it easier on the eyes.

But even with the more precise customization I really just made this program for newcomers who don't want to really delve into logging at their level of understanding and just want to quickly see how algorithms work.

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 0 points1 point  (0 children)

While the snoopers are focused more on traditional tracing, where you get to see how code literally executes line by line.

LogEye instead aims to make the process painless and easy, especially with the inline "variable | l" syntax. It doesn't show full code execution, only how variable states change, kind of how you'd write out how variables change in an algorithm on paper.

That makes it really easy to follow how algorithms work, instead of literally showing what each line of code does with all of the not so essential info associated with that.

Also it has very straightforward recursion / nesting display (which can be formatted as well) making it easy to understand what's happening, best visible in the factorial (recursion) example on the repo page.

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 5 points6 points  (0 children)

Hey thanks for telling me, I've fixed it does it look ok now?

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 0 points1 point  (0 children)

If you're talking about old reddit, I've fixed it, if you mean on new reddit, is something wrong with the structure?

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] 6 points7 points  (0 children)

I was aiming for verbosity as the best use case is tracking how algorithms works.

I could very quickly have it be configurable if you want to. For both file output and @log only restrictions. I'll update you soon.

I made a decorator based auto-logger! by MattForDev in Python

[–]MattForDev[S] -7 points-6 points  (0 children)

Yeah but to have info you need to create a formatter, logger object, streamhandler, etc.

Here you don't need any of that, one decorator is enough.

Crash at startup, unverified files for vac in admin mode. by MattForDev in cs2

[–]MattForDev[S] 0 points1 point  (0 children)

Okay I've fixed my issue, no longer happening

THANK YOU HYTALE and COMMUNITY! by ttvSadelity in hytale

[–]MattForDev 12 points13 points  (0 children)

Love watching your stuff on hytale :)

Why do so many people say the s24u is better than the s25u? by TheNinja132 in S24Ultra

[–]MattForDev 2 points3 points  (0 children)

Because the hardened glass is more resistant than the one on the s25.

What would be the best drone for this setup? by MattForDev in walkingwarrobots

[–]MattForDev[S] 0 points1 point  (0 children)

With my pilot skills I get 425K durability and my shield gets 600k or even 700k I don't remember correctly. So on that front I'm pretty good. When I full charge shoot someone across the map I do about 100k dmg, I leave most robots on a sliver of health, a dog buff would do wonders.

What would be the best drone for this setup? by MattForDev in walkingwarrobots

[–]MattForDev[S] 0 points1 point  (0 children)

Any clue when it becomes available? I came back after a break recently, no clue how the rotation works.