-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add built-in logging support and other fixes #566
Merged
mkilgore
merged 8 commits into
QB64-Phoenix-Edition:main
from
mkilgore:logging-changes-2
Dec 4, 2024
Merged
Add built-in logging support and other fixes #566
mkilgore
merged 8 commits into
QB64-Phoenix-Edition:main
from
mkilgore:logging-changes-2
Dec 4, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkilgore
requested review from
grymmjack,
flukiluke,
SteveMcNeill,
a740g and
RhoSigma-QB64
November 10, 2024 05:55
a740g
approved these changes
Nov 10, 2024
mkilgore
force-pushed
the
logging-changes-2
branch
2 times, most recently
from
November 22, 2024 06:57
251dcbc
to
ee1e23e
Compare
mkilgore
changed the title
[WIP] Add built-in logging support and other fixes
Add built-in logging support and other fixes
Nov 22, 2024
This is ready to be reviewed, there's a couple other things to do (IDE dialog for configuring logging, convert the audio logging, coloring the output, etc.) but those can be left for separate PRs. |
RhoSigma-QB64
approved these changes
Nov 22, 2024
mkilgore
force-pushed
the
logging-changes-2
branch
2 times, most recently
from
November 26, 2024 03:06
6709614
to
abd23ac
Compare
This was referenced Nov 26, 2024
mkilgore
force-pushed
the
logging-changes-2
branch
from
November 27, 2024 02:41
abd23ac
to
07758bd
Compare
This change allows QB64 programs to send stdout output to their parent console if started from one. This works regardless of `$CONSOLE` usage, which is useful for `_Echo` and `_Log*` statements which can always go to console regardless of `$CONSOLE` settings. We also allow a msys or cygwin pipe to be used in place of a proper console, as that's good enough for our basic output from `_Echo` and `_Log*` statements (and more convient than starting a separate console window). If we're an actual `$CONSOLE` program than a separate console will always be started.
On Windows, if the time goes backwards (IE. someone sets the system date to an earlier time) then `clock()` starts returning large negative values. To avoid this we're switching GetTicks to use a different Windows API to track the time since the start of the program.
This allows the user to enable logging from within the IDE. When they do this, environment variables will be set to turn on logging to console at Information level with a default set of logging scopes. The program is started with a separate console to allow the logging to be viewed separate from the program (unless the program is $Console:Only and has no graphical view). The terminal configuration is specific for Linux and used for both logging output and $Console programs. It allows the user to configure a terminal emulator to be used for running programs, allowing the output of $Console programs to be viewed from it as well as logging output when enabled. When no terminal is configured we have logic that checks a list of common terminal emulators to see if any of them are availiable, and if so uses a known good configuration for them. The user can change this via a GUI dialog.
mkilgore
force-pushed
the
logging-changes-2
branch
from
December 4, 2024 03:43
07758bd
to
a6bcb2a
Compare
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is getting close to being ready so I wanted to get some eyes on it:
This adds new logging capabilities to QB64, both internally from
libqb
and also exposed to the QB64 code. Beyond being a bit nicer thanPrint
s since it captures the function name and line number, a big feature is that logging an error captures a stacktrace of the program at that point. Logging can also easily be turned on without recompilation via environment variables, and can be filtered via various scopes and a couple different logging levels. Overall this should hopefully be a big aid for debugging, as we can ask users to provide us with the logging output of programs when they error.Below is an example of some logging from a QB64 program (note how the IDE opens a separate console window to display it):
The new commands are
_LogTrace
,_LogInfo
,_LogWarn
,_LogError
,_LogMinLevel
. The first four write out log messages at the indicated log level. The last returns a number indicating the lowest level of logging is enabled, allowing you to skip generating more expensive logging if it won't be displayed.Logging is enabled via a variety of different environment variables (when run from the IDE these are configured automatically):
QB64PE_LOG_LEVEL
- sets the lowest log level to display, options areTrace
,Information
,Warning
,Error
QB64PE_LOG_SCOPES
- A comma-separated list of different sets of logging to turn on, allowing basic filtering of what is displayed. Options are:a.
libqb
- Some generic logging fromlibqb
, such as error codes when they happen, program startup/shutdown, etc.b.
libqb-image
- Logging from the image subsystem (when images are loaded,freed, errors that happen, etc.)c.
libqb-audio
- Logging from the audio subsystemd.
qb64
- Logging from the QB64 Program (_Log*
statements)QB64PE_LOG_HANDLERS
- A comma-separated list of the logging handlers to enable. If no handlers are enabled, then no logging is generated. Current options are:a.
console
- Logging output is written to the console.b.
file
- Writes logs to the file set via theQB64PE_LOG_FILE_PATH
environment variableCurrently the IDE just defaults to using
Information
and enabling all the scopes, in a future update I'd like to have an IDE dialog that lets you pick the log level and scopes.