Closed Jafaral closed 1 month ago
@Don-Ward I agree. Those are good suggestions, but I'm trying to get something going in the short term. I updated the PR to allow defining debug classes/filters. I added a c command line option just as an example, with a couple of debug message use case for demonstration purposes. A log message will be printed if the log level is high enough for it to be printed, or it matches a calls/filter. Filter supports sub-classes too. Ex:
jafar@jtr:ulsp$ ./ulsp --socket 12345 -s --debugfilter "db:path"
[debug:db:path] /home/jafar/unicon/ipl/lib
[debug:db:path] /home/jafar/unicon/uni/lib
[debug:db:path] /home/jafar/unicon/uni/gui
[debug:db:path] /home/jafar/unicon/uni/xml
[debug:db:path] /home/jafar/unicon/uni/3d
[debug:db:path] /home/jafar/unicon/plugins/lib
[debug:db:path] /home/jafar/unicon/ipl/procs
[debug:db:path] /home/jafar/unicon/uni/unidoc
^C
shutdown signal received! Server Shutting down...
jafar@jtr:ulsp$ ./ulsp --socket 12345 -s --debugfilter "db"
[debug:db]Looking in 1
[debug:db:path] /home/jafar/unicon/ipl/lib
[debug:db:path] /home/jafar/unicon/uni/lib
[debug:db:path] /home/jafar/unicon/uni/gui
[debug:db:path] /home/jafar/unicon/uni/xml
[debug:db:path] /home/jafar/unicon/uni/3d
[debug:db:path] /home/jafar/unicon/plugins/lib
[debug:db:path] /home/jafar/unicon/ipl/procs
[debug:db:path] /home/jafar/unicon/uni/unidoc
^C
shutdown signal received! Server Shutting down...
jafar@jtr:ulsp$ ./ulsp --socket 12345 -s --debugfilter "db" --loglevel 10
[info]Loading Database...
[debug:db]Looking in 1
[debug:db:path] /home/jafar/unicon/ipl/lib
[debug:db:path] /home/jafar/unicon/uni/lib
[debug:db:path] /home/jafar/unicon/uni/gui
[debug:db:path] /home/jafar/unicon/uni/xml
[debug:db:path] /home/jafar/unicon/uni/3d
[debug:db:path] /home/jafar/unicon/plugins/lib
[debug:db:path] /home/jafar/unicon/ipl/procs
[debug:db:path] /home/jafar/unicon/uni/unidoc
[info]Starting Unicon LSP in server mode at :12345
I made further updates, changing the filtering logic based on testing I did. I also changed "filter" to "class". Log level now much be 8+ for filters to work, I.e, debugging must be enabled. I added flush
, but chose to ignore threads for now. The class is a bit thread "friendly" already, but it is good to add support so that each log is written out to all log destinations from one thread before processing a new log request.
jafar@mac16 ulsp % ./ulsp --socket 12345 --loglevel 8 --debug-class "db:path:package"
[info] Loading Database...
[debug3:db:path:package] Processing (main)
[debug3:db:path:package] Processing doptions
[debug3:db:path:package] Processing exception
[debug3:db:path:package] Processing lang
example log file
./ulsp --socket 12345 --loglevel 8 --debug-class "db:path" --logfile /tmp/ulsp.log
jafar@mac16 ulsp % cat /tmp/ulsp.log
[2024/09/17 00:36:21][info] Loading Database...
[2024/09/17 00:36:21][debug2:db:path] Processing /Users/jafar/proj/unicon/ipl/lib
[2024/09/17 00:36:21][debug2:db:path] Processing /Users/jafar/proj/unicon/uni/lib
[2024/09/17 00:36:23][debug2:db:path] Processing /Users/jafar/proj/unicon/uni/gui
[2024/09/17 00:36:23][debug2:db:path] Processing /Users/jafar/proj/unicon/uni/xml
[2024/09/17 00:36:24][debug2:db:path] Processing /Users/jafar/proj/unicon/uni/3d
[2024/09/17 00:36:24][debug2:db:path] Processing /Users/jafar/proj/unicon/plugins/lib
[2024/09/17 00:36:24][debug2:db:path] Processing /Users/jafar/proj/unicon/ipl/procs
[2024/09/17 00:36:26][debug2:db:path] Processing /Users/jafar/proj/unicon/uni/unidoc
[2024/09/17 00:36:26][info] Starting Unicon LSP in server mode at 127.0.0.1:12345
[2024/09/17 00:36:31][notice]
shutdown signal received! Server Shutting down...
This adds a general logging class that I hope to move to the library. For now keeping it and using it in ulsp.
example run