Skip to content

Conversation

marcin-cebo
Copy link
Contributor

@marcin-cebo marcin-cebo commented Sep 1, 2025

feat: Added structured log statements throughout the system in transport layer, crypto module, serialization, API calls, etc.
feat: Added deprecation warning for logVerbosity and httpLoggingInterceptor config params

Added deprecation warning for logVerbosity and httpLoggingInterceptor config params. For logging configuration we advise using SLF4J implementation lib like logback or log4j2 and their config capabilities.

feat: Added new config property called customLoggers

Added new config property called customLoggers, which can bu used when customer needs can not be implemented using configuration options of SLF4J implementation libs like logback or log4j2.

*/
val httpLoggingInterceptor: HttpLoggingInterceptor?
@Deprecated(
message = "This setting is deprecated. Use customLoggers instead",
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: There's an extra space between customLoggers and instead

Copy link
Contributor Author

@marcin-cebo marcin-cebo Sep 9, 2025

Choose a reason for hiding this comment

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

Good catch. I will fix that.

message = "This setting is deprecated. Use customLoggers instead",
level = DeprecationLevel.WARNING
)
val httpLoggingInterceptor: HttpLoggingInterceptor? // todo deprecate
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps // todo deprecate comment is no longer required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course. Good catch. I will fix that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I will fix that.

* @see [HttpLoggingInterceptor]
*/
@Deprecated(
message = "This setting is deprecated. Use customLoggers instead",
Copy link
Contributor

Choose a reason for hiding this comment

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

The same nitpick as above, there's an extra space between customLoggers and instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I will fix that.

pnConfiguration.retryConfiguration(RetryConfiguration.None.INSTANCE);
pnConfiguration.logVerbosity(PNLogVerbosity.NONE);
pnConfiguration.httpLoggingInterceptor(createInterceptor());
// pnConfiguration.httpLoggingInterceptor(createInterceptor()); // todo remove when logging is implemented
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment up to date?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. I will remove it.

}

// this method is used from cryptoModuleWithLogConfig using reflection
fun getCryptoModuleWithLogConfig(logConfig: LogConfig): CryptoModule? {
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of this method? Is it to inject logConfig property to CryptoModule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why customer creates cryptoModule it create it without logConfig. It is hidden from them. Then we need to add logConfig so that cryptoModule operations can be logged.

override fun presenceTimeout(presenceTimeout: Int): Builder {
this.presenceTimeout = if (presenceTimeout < MINIMUM_PRESENCE_TIMEOUT) {
log.warn("Presence timeout is too low. Defaulting to: $MINIMUM_PRESENCE_TIMEOUT")
println("Presence timeout is too low. Defaulting to: $MINIMUM_PRESENCE_TIMEOUT")
Copy link
Contributor

@jguz-pubnub jguz-pubnub Sep 8, 2025

Choose a reason for hiding this comment

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

Is it possible to inject logger property in PNConfigurationImpl?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately not. To create logger we need to know logConfig which is created when creating PubNub.
Current order is:

  1. Create PnConfiguration
  2. Create instanceId while creating PubNub
  3. Create logger

override val authKey: String = "",
override val authToken: String? = null,
override val cryptoModule: CryptoModule? = null,
override val cryptoModule: CryptoModule? = null, // don't use getter directly use getCryptoModuleWithLogConfig to be able to properly configure logging in CryptoModule
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this somehow customer-facing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is internal note. This is hidden in implementation module.
Customers will interact with an interface and they are supposed to set clean cryptoModule. Internally we add to it LogConfig so it is possible to log info about crypto module operations.

@jguz-pubnub jguz-pubnub self-requested a review September 11, 2025 09:23
@marcin-cebo
Copy link
Contributor Author

@pubnub-release-bot release kotlin as v10.6.0

@marcin-cebo marcin-cebo merged commit b910d80 into master Sep 11, 2025
7 checks passed
@marcin-cebo marcin-cebo deleted the mc_logging_to_portal branch September 11, 2025 11:23
@pubnub-release-bot
Copy link
Contributor

🚀 Release successfully completed 🚀

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

Successfully merging this pull request may close these issues.

3 participants