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

Include identity of component that emitted a log message, where applicable #1659

Open
lawrence-forooghian opened this issue Apr 13, 2023 · 1 comment
Labels
enhancement New feature or improved functionality.
Milestone

Comments

@lawrence-forooghian
Copy link
Collaborator

lawrence-forooghian commented Apr 13, 2023

Background

Many of the log messages emitted by the SDK are emitted by a specific instance of a class.

We would like all such messages to include some generally-useful information about this instance.

Requirements

Each message logged by a class instance should include the following information:

  • the name of the class of the object
  • the address of the object

Logging API considerations (falls under #1617)

The above should be implemented in a way that is consistent throughout the codebase and which is easy to include in new log messages. This means exposing an internal logging API that helps us to emit this information.

I’d suggest embedding this information in the logger object — i.e. so that there is a 1-1 correspondence between logger instances and SDK object instances. This could, for example, be achieved by adding a method to ARTInternalLog for creating a new logger from an existing one, given some metadata, e.g. -[ARTInternalLog loggerForObject:(id)object].

Prior art

What I’m suggesting above is based on the way we do logging in the Asset Tracking SDK. When creating a new object, we also create a new InternalLogHandler instance which stores information about the object that created it (example).

Current state

Our existing log messages often include the address of the object that emitted them, but it is done in an ad-hoc fashion (i.e. needing to remember to include "RT: %p" at the start of the message). For example:

ARTLogWarn(self.logger, @"RT:%p connection \"%@\" has reconnected, but resume failed. Reattaching any attached channels", self, message.connectionId);

┆Issue is synchronized with this Jira Task by Unito

@lawrence-forooghian lawrence-forooghian added this to the Logging milestone Apr 13, 2023
@sync-by-unito
Copy link

sync-by-unito bot commented Apr 13, 2023

➤ Automation for Jira commented:

The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3533

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improved functionality.
Development

No branches or pull requests

2 participants