Add persistent log - #121
Conversation
|
INFO: No unicode characters found in PR's commits (source) |
|
Hi @Raihan93-coder thanks for the PR :) Sorry if this wasn't clear, but the reason that #34 was blocked by #16 was that this was supposed to be setup in a config file option, not as an argument (eg Issue #16 added a config file ( Can you please update this PR to use a config option in |
|
See also the docs for And how we implement this in our current setting buskill-app/src/packages/buskill/__init__.py Lines 943 to 950 in 4504d00 |
|
INFO: No unicode characters found in PR's commits (source) |
|
I have made the changes as you suggested The present implementation works for cases like
I have checked all these cases and it is working perfectly as intended |
|
INFO: No unicode characters found in PR's commits (source) |
|
INFO: No unicode characters found in PR's commits (source) |
|
in my testing, I discovered a bug I don't think this is related to your changes. I guess it happens when the buskill-app/src/packages/buskill/__init__.py Lines 881 to 911 in 33dd42f In another ticket, we should probably add logic that attempts to create the path to the |
Persistent Logging
I have implemented the persistent logging feature in CLI, I have not integrated it in GUI, The idea is simple if the user have given a debug flag in the terminal then instead of the program writing the log to /tmp/buskill.log, it will write to DATA_DIR/buskill.log.
The CLI work around of getting the bool is a bit clumsy but I have also added a reference link from stack-overflow, If you wanted I can implement that instead of the present implementation style
Problems faced
There was quite a lot of challenges That I have faced, And some was quite hilarious as I was trying to solve the problem which I had already solved earlier but still was trying to wrap my brain around it
Logging was initialized before BusKill() instantiation The biggest issue was that logging initialization happens very early in main.py, before the BusKill object is instantiated. This created an architectural issue because, DATA_DIR only becomes available after BusKill() initialization, but the logging path must be decided before logging initialization, This prevented directly using bk.DATA_DIR during initial log setup.
logger.root.handlers[0] indexing issue; Inside BusKill.init, the following line caused an indexing error if logging had not already been initialized self.LOG_FILE_PATH = logger.root.handlers[0].baseFilename This meant:
This circular dependency was the main source of the implementation difficulty.
This was Issue I was taking earlier 😭
Initially I introduced self.persistent_log = False inside BusKill.init. Then inside buskill_cli.py buskill_object.persistent_log = args.debug However, the value appeared unchanged in main.py. After debugging with id() checks, I discovered; different BusKill() instances were being referenced logging initialization occurred before CLI argument processing, So the --debug argument was being applied too late to influence the initial log path.
Conclusion
I checked the working across root and regular user and it is working as intended
The path to DATA_DIR in my case is the <user_dir>/.local/share/.buskill/buskill.log across both root and regular user
If any problem or implementation logic flaw exist please let me know and I will also give you the reference link to the stack-overflow solution that I was referring down below
stack_overflow_solution
Sincerely,
Raihan 🤓