Skip to content
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

change(mac): adopt unified logging APIs #11515

Merged
merged 6 commits into from
May 27, 2024

Conversation

sgschantz
Copy link
Contributor

@sgschantz sgschantz commented May 23, 2024

  • Create os_log_t objects to identify different parts of the application for logging purposes
  • Define subystem and categories to use for filtering log statements
  • Call unified logging APIs os_log, os_log_error, os_log_info and os_log_debug to record log statements.
  • Remove all references to logDebugMessage and the NSLog macro, as they do not use unified logging (and do not specify subsystem and category)

Fixes #10997

@keymanapp-test-bot skip

sgschantz added 5 commits May 20, 2024 08:42
delete commented out code and unimplemented method
KMLogs creates singleton os_log objects with the subsystem
and categories shared throughout the application
first draft, need to remove some debug statements and replace
others that would be more useful
remove logDebugMessage API which calls NSLog and call os_log instead
remove all references to NSLog
adjust log level for some calls to os_log
Fixes #10997
@sgschantz sgschantz added the mac/ label May 23, 2024
@sgschantz sgschantz added this to the A18S2 milestone May 23, 2024
@sgschantz sgschantz self-assigned this May 23, 2024
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented May 23, 2024

User Test Results

Test specification and instructions

User tests are not required

@sgschantz sgschantz marked this pull request as ready for review May 24, 2024 00:37
@sgschantz sgschantz requested a review from SabineSIL as a code owner May 24, 2024 00:37
@sgschantz sgschantz changed the title Fix(mac): adopt unified logging APIs Chore(mac): adopt unified logging APIs May 24, 2024
@mcdurdin mcdurdin changed the title Chore(mac): adopt unified logging APIs chore(mac): adopt unified logging APIs May 24, 2024
@mcdurdin mcdurdin changed the title chore(mac): adopt unified logging APIs change(mac): adopt unified logging APIs May 24, 2024
@mcdurdin mcdurdin modified the milestones: A18S2, A18S3 May 24, 2024
Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits only, LGTM.

I think we should use com.keyman and not org.sil.keyman as our namespace -- we have keyman.com as a domain but not keyman.sil.org (if we went that way it probably should be org.sil.software.keyman).

I also added .app and .engine so that com.keyman was grouping namespace, with submodules beneath that.


const NSString *kConnectionName = @"Keyman_Input_Connection";
IMKServer *server;

int main(int argc, const char * argv[]) {
NSString *identifier;
os_log_t configLog = os_log_create("org.sil.keyman", "startup");
NSString *identifier;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NSString *identifier;
NSString *identifier;

NSData* data = [self.textToInsert dataUsingEncoding:NSUTF16LittleEndianStringEncoding];

return [[NSString alloc] initWithFormat: @"codePointsToDeleteBeforeInsert: %li, textToInsert: '%@', optionsToPersist: %@, alert: %d, emitKeystroke: %d, capsLockState: %d ", self.codePointsToDeleteBeforeInsert, data, self.optionsToPersist, self.alert, self.emitKeystroke, self.capsLockState];
NSData* deleteData = [self.textToDelete dataUsingEncoding:NSUTF16LittleEndianStringEncoding];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically this is a change in behaviour -- just checking that self.textToDelete is never null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description method is called to log the CoreKeyOutput state from CoreWrapper processMacVirtualKey. Both textToInsert and textToDelete can be null, but if they are, then dataUsingEncoding returns null, and the log statement will say textToDelete: '(null)' [data: '(null)']

Because this is being logged with a debug statement, this description method will only be executed when the user is streaming debug logs.


@implementation KMELogs

char *const keymanEngineSubsystem = "org.sil.keymanengine";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
char *const keymanEngineSubsystem = "org.sil.keymanengine";
char *const keymanEngineSubsystem = "com.keyman.engine";


@implementation KMLogs

char *const keymanSubsystem = "org.sil.keyman";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
char *const keymanSubsystem = "org.sil.keyman";
char *const keymanSubsystem = "com.keyman.app";

@@ -21,7 +22,7 @@ - (id)initWithFilePath:(NSString *)path {

NSFileHandle *file = [NSFileHandle fileHandleForReadingAtPath:path];
if (file == nil) {
//NSLog(@"Failed to open kvk file");
os_log_error([KMELogs configLog], "Failed to open kmx file");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
os_log_error([KMELogs configLog], "Failed to open kmx file");
os_log_error([KMELogs configLog], "Failed to open kvk file");

address review comments
@sgschantz sgschantz merged commit b068f94 into master May 27, 2024
3 checks passed
@sgschantz sgschantz deleted the fix/mac/10997-adopt-unified-logging branch May 27, 2024 02:11
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.45-alpha

6 similar comments
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.45-alpha

@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.45-alpha

@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.45-alpha

@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.45-alpha

@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.45-alpha

@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 18.0.45-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chore(mac): Use unified logging APIs
3 participants