Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c15e464
Initial code. Not compiling.
marcin-cebo Jul 2, 2025
e7b787d
Improvements
marcin-cebo Jul 4, 2025
de87f5c
Added logging of configuration on PubNub instance creation and config…
marcin-cebo Jul 8, 2025
5f3eb75
Added logging of configuration on PubNub instance creation and config…
marcin-cebo Jul 8, 2025
ded8c28
Added test for logging the configuration
marcin-cebo Jul 8, 2025
304a278
Fix lint
marcin-cebo Jul 8, 2025
be345c6
Refactor of CompositeLogger
marcin-cebo Aug 5, 2025
f2fff34
Added tests
marcin-cebo Aug 5, 2025
dc39416
Deprecate logVerbosity
marcin-cebo Aug 5, 2025
a3aaf96
Added test for customLogger
marcin-cebo Aug 6, 2025
c6ae7d0
Removed maxBodySize
marcin-cebo Aug 6, 2025
1d009f9
Lint
marcin-cebo Aug 6, 2025
bc43c5b
Added some tests
marcin-cebo Aug 6, 2025
4093427
Removed identifier from networkRequest log
marcin-cebo Aug 8, 2025
487a27c
Added logging of API calls parameters in trace level
marcin-cebo Aug 8, 2025
206a809
Added logging of EventEngine effects.
marcin-cebo Aug 8, 2025
bb7f6d4
Added logging of EventEngine effects dispatch operations.
marcin-cebo Aug 26, 2025
bd52e07
Added logging of EventEngine transition.
marcin-cebo Aug 26, 2025
4457e4e
Added logging of CryptModule operations
marcin-cebo Sep 1, 2025
ac01473
Added deprecation warning for httpLoggingInterceptor and logVerbosity
marcin-cebo Sep 1, 2025
b292a7f
Introduced new logging approach in ListenerManager
marcin-cebo Sep 1, 2025
2ce7088
Introduced new logging approach in tests
marcin-cebo Sep 2, 2025
249aecf
Introduced new logging approach in tests
marcin-cebo Sep 2, 2025
4582f62
Introduced new logging approach
marcin-cebo Sep 2, 2025
802897e
Introduced new logging approach
marcin-cebo Sep 2, 2025
fe104d7
Introduced new logging approach
marcin-cebo Sep 2, 2025
f981425
Renamed ExtendedLogger to PNLogger
marcin-cebo Sep 2, 2025
c61a2dc
Removed logLevel and type from log statements
marcin-cebo Sep 3, 2025
c165a40
Fixed tests
marcin-cebo Sep 3, 2025
10ce8a3
Infer type of LogMessage
marcin-cebo Sep 4, 2025
018784a
Added logging of deprecation method usage.
marcin-cebo Sep 4, 2025
728e64b
Addd logging for serialization and deserialization.
marcin-cebo Sep 4, 2025
7b2fddb
Change order of properties in LogMessage
marcin-cebo Sep 4, 2025
f5cb8e1
Infer location if not present in LogMessage
marcin-cebo Sep 4, 2025
df1413e
Disabled ToPortalLogger since it is not fully implemented.
marcin-cebo Sep 5, 2025
078f7a8
Fixed tests
marcin-cebo Sep 5, 2025
4a2ee3d
Fixed retrieving cryptoModuleWithLogConfig in java
marcin-cebo Sep 5, 2025
1e2cac5
Fixed
marcin-cebo Sep 5, 2025
a1ef053
Codacy fix
marcin-cebo Sep 5, 2025
8a04adf
Fixed review comments.
marcin-cebo Sep 10, 2025
696761e
PubNub SDK v10.6.0 release.
pubnub-release-bot Sep 11, 2025
100a395
Fixed changelog entry.
marcin-cebo Sep 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: kotlin
version: 10.5.8
version: 10.6.0
schema: 1
scm: github.com/pubnub/kotlin
files:
- build/libs/pubnub-kotlin-10.5.8-all.jar
- build/libs/pubnub-kotlin-10.6.0-all.jar
sdks:
-
type: library
Expand All @@ -23,8 +23,8 @@ sdks:
-
distribution-type: library
distribution-repository: maven
package-name: pubnub-kotlin-10.5.8
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/10.5.8/pubnub-kotlin-10.5.8.jar
package-name: pubnub-kotlin-10.6.0
location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/10.6.0/pubnub-kotlin-10.6.0.jar
supported-platforms:
supported-operating-systems:
Android:
Expand Down Expand Up @@ -121,6 +121,15 @@ sdks:
license-url: https://www.apache.org/licenses/LICENSE-2.0.txt
is-required: Required
changelog:
- date: 2025-09-11
version: v10.6.0
changes:
- type: feature
text: "Added structured log statements throughout the system in transport layer, crypto module, serialization, API calls, etc."
- type: feature
text: "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."
- type: feature
text: "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."
- date: 2025-08-06
version: v10.5.8
changes:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v10.6.0
September 11 2025

#### Added
- Added structured log statements throughout the system in transport layer, crypto module, serialization, API calls, etc.
- 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.
- 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.

## v10.5.8
August 06 2025

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
<dependency>
<groupId>com.pubnub</groupId>
<artifactId>pubnub-kotlin</artifactId>
<version>10.5.8</version>
<version>10.6.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RELEASE_SIGNING_ENABLED=true
SONATYPE_HOST=DEFAULT
SONATYPE_AUTOMATIC_RELEASE=false
GROUP=com.pubnub
VERSION_NAME=10.5.8
VERSION_NAME=10.6.0
POM_PACKAGING=jar

POM_NAME=PubNub SDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.pubnub.api.UserId
import com.pubnub.api.crypto.CryptoModule
import com.pubnub.api.enums.PNHeartbeatNotificationOptions
import com.pubnub.api.enums.PNLogVerbosity
import com.pubnub.api.logging.CustomLogger
import com.pubnub.api.retry.RetryConfiguration
import okhttp3.Authenticator
import okhttp3.CertificatePinner
Expand Down Expand Up @@ -91,6 +92,13 @@ interface PNConfiguration : com.pubnub.api.v2.PNConfiguration {
/**
* Set to [PNLogVerbosity.BODY] to enable logging of network traffic, otherwise se to [PNLogVerbosity.NONE].
*/
@Deprecated(
message = "LogVerbosity setting is deprecated and will be removed in future versions. " +
"For logging configuration:\n" +
"1. Use an SLF4J implementation (recommended)\n" +
"2. Or implement CustomLogger interface and set via customLoggers property",
level = DeprecationLevel.WARNING
)
val logVerbosity: PNLogVerbosity

/**
Expand Down Expand Up @@ -248,6 +256,10 @@ interface PNConfiguration : com.pubnub.api.v2.PNConfiguration {
*
* @see [HttpLoggingInterceptor]
*/
@Deprecated(
message = "This setting is deprecated. Use customLoggers instead",
level = DeprecationLevel.WARNING
)
val httpLoggingInterceptor: HttpLoggingInterceptor?

/**
Expand Down Expand Up @@ -301,6 +313,12 @@ interface PNConfiguration : com.pubnub.api.v2.PNConfiguration {
*/
val managePresenceListManually: Boolean

/**
* Custom loggers list for creating additional logger instances.
* Use it if your slf4j implementation like logback, log4j2, etc. can't meet your specific logging requirements.
*/
val customLoggers: List<CustomLogger>?

override fun build(): PNConfiguration

override fun setUserId(userId: UserId): Builder
Expand Down Expand Up @@ -337,6 +355,13 @@ interface PNConfiguration : com.pubnub.api.v2.PNConfiguration {
/**
* Set to [PNLogVerbosity.BODY] to enable logging of network traffic, otherwise se to [PNLogVerbosity.NONE].
*/
@Deprecated(
message = "LogVerbosity setting is deprecated and will be removed in future versions. " +
"For logging configuration:\n" +
"1. Use an SLF4J implementation (recommended)\n" +
"2. Or implement CustomLogger interface and set via customLoggers property",
level = DeprecationLevel.WARNING
)
fun logVerbosity(logVerbosity: PNLogVerbosity): Builder

/**
Expand Down Expand Up @@ -479,6 +504,10 @@ interface PNConfiguration : com.pubnub.api.v2.PNConfiguration {
*
* @see [HttpLoggingInterceptor]
*/
@Deprecated(
message = "This setting is deprecated. Use customLoggers instead",
level = DeprecationLevel.WARNING
)
fun httpLoggingInterceptor(httpLoggingInterceptor: HttpLoggingInterceptor?): Builder

/**
Expand Down Expand Up @@ -533,6 +562,12 @@ interface PNConfiguration : com.pubnub.api.v2.PNConfiguration {
* @see PNConfigurationImpl.heartbeatInterval
*/
fun managePresenceListManually(managePresenceListManually: Boolean): Builder

/**
* Custom loggers list for creating additional logger instances.
* Use it if your slf4j implementation like logback, log4j2, etc. can't meet your specific logging requirements.
*/
fun customLoggers(customLoggers: List<CustomLogger>?): Builder
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.pubnub.api.integration;

import com.pubnub.api.PubNubException;
import com.pubnub.api.UserId;
import com.pubnub.api.integration.util.BaseIntegrationTest;
import com.pubnub.api.integration.util.CustomLoggerTestImpl;
import com.pubnub.api.integration.util.ITTestConfig;
import com.pubnub.api.integration.util.RandomGenerator;
import com.pubnub.api.java.PubNub;
import com.pubnub.api.java.v2.PNConfiguration;
import com.pubnub.api.logging.LogMessageContent;
import com.pubnub.api.logging.LogMessageType;
import org.aeonbits.owner.ConfigFactory;
import org.junit.Test;

import java.util.Collections;
import java.util.UUID;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class LoggingIntegrationTest extends BaseIntegrationTest {
final ITTestConfig itTestConfig = ConfigFactory.create(ITTestConfig.class, System.getenv());

@Test
public void testCanLogMessagesUsingCustomLogger() throws PubNubException, InterruptedException {
// Clear any previous messages
CustomLoggerTestImpl.clear();

String expectedUuid = UUID.randomUUID().toString();
String expectedChannel = "test-channel-" + RandomGenerator.newValue(8);

PNConfiguration.Builder configBuilder = PNConfiguration.builder(
new UserId(expectedUuid),
itTestConfig.subscribeKey()
);
configBuilder.publishKey(itTestConfig.publishKey());
configBuilder.customLoggers(Collections.singletonList(new CustomLoggerTestImpl()));

PubNub pubNub = PubNub.create(configBuilder.build());

// Publish a message to generate logs
pubNub.publish()
.channel(expectedChannel)
.message(generatePayload())
.customMessageType("myType")
.sync();

// Verify logging
assertFalse("Should have received string messages", CustomLoggerTestImpl.stringMessages.isEmpty());
assertFalse("Should have received LogMessage objects", CustomLoggerTestImpl.logMessages.isEmpty());

// Verify content - string messages
assertTrue(
"Should have called publish on the expected channel",
CustomLoggerTestImpl.stringMessages.stream().anyMatch(msg ->
msg.contains("PublishEndpoint") && msg.contains(expectedChannel)
)
);

assertTrue(
"Should have called publish on the expected channel",
CustomLoggerTestImpl.stringMessages.stream().anyMatch(msg ->
msg.contains("NetworkRequest") && msg.contains(expectedChannel)
)
);

assertTrue(
"Should have called publish on the expected channel",
CustomLoggerTestImpl.stringMessages.stream().anyMatch(msg ->
msg.contains("NetworkResponse") && msg.contains(expectedChannel)
)
);

// Verify content - LogMessage objects
assertTrue(
"Should have called publish on the expected channel",
CustomLoggerTestImpl.logMessages.stream().anyMatch(msg ->
msg.getType() == LogMessageType.OBJECT &&
msg.getLocation().contains("PublishEndpoint") &&
(msg.getMessage() instanceof LogMessageContent.Object) &&
expectedChannel.equals(((LogMessageContent.Object) msg.getMessage()).getMessage().get("channel"))
)
);

assertTrue(
"Should have called publish API. LogMessage type should be NETWORK_REQUEST",
CustomLoggerTestImpl.logMessages.stream().anyMatch(msg ->
msg.getType() == LogMessageType.NETWORK_REQUEST &&
msg.getLocation().contains("publish")
)
);

assertTrue(
"Should have called publish API. LogMessage type should be NETWORK_RESPONSE",
CustomLoggerTestImpl.logMessages.stream().anyMatch(msg ->
msg.getType() == LogMessageType.NETWORK_RESPONSE &&
msg.getLocation().contains("publish")
)
);

pubNub.destroy();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public void onMore(List<PNMessageAction> actions) {

@Override
public void onDone() {
log.error(String.format("onDone %s", count.get()));
System.out.println(String.format("onDone %s", count.get()));
success.set(count.get() == messageCount);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.pubnub.api.PubNubException;
import com.pubnub.api.UserId;
import com.pubnub.api.integration.util.CustomLoggerTestImpl;
import com.pubnub.api.integration.util.ITTestConfig;
import com.pubnub.api.integration.util.Utils;
import com.pubnub.api.java.PubNub;
Expand All @@ -11,6 +12,8 @@
import org.junit.Assert;
import org.junit.Test;

import java.util.Arrays;

public class PNConfigurationIntegrationTests {
final ITTestConfig itTestConfig = ConfigFactory.create(ITTestConfig.class, System.getenv());

Expand All @@ -35,12 +38,14 @@ public void createConfigurationWithConfigurationActionBlock() throws PubNubExcep
String expectedUuid = PubNub.generateUUID();

PNConfiguration.Builder configBuilder = PNConfiguration.builder(new UserId(expectedUuid), itTestConfig.subscribeKey())
.publishKey(itTestConfig.publishKey());
.publishKey(itTestConfig.publishKey())
.customLoggers( Arrays.asList(new CustomLoggerTestImpl()));
PubNub pubNub = PubNub.create(configBuilder.build());

Assert.assertEquals(expectedUuid, pubNub.getConfiguration().getUserId().getValue());
Assert.assertEquals(itTestConfig.subscribeKey(), pubNub.getConfiguration().getSubscribeKey());
Assert.assertEquals(itTestConfig.publishKey(), pubNub.getConfiguration().getPublishKey());
Assert.assertTrue(pubNub.getConfiguration().getCustomLoggers().get(0) instanceof CustomLoggerTestImpl);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.jetbrains.annotations.NotNull;
import org.junit.After;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.HashMap;
Expand All @@ -35,7 +33,6 @@
import static org.junit.Assert.assertNotNull;

public class ChannelMetadataIT extends ObjectsApiBaseIT {
private static final Logger LOG = LoggerFactory.getLogger(ChannelMetadataIT.class);
private static final int NUMBER_OF_RANDOM_TEST_NAMES = 10;
private static final int FETCH_LIMIT = 3;

Expand Down Expand Up @@ -272,7 +269,7 @@ public void cleanUp() {
.channel(setChannelMetadataResult.getData().getId())
.sync();
} catch (Exception e) {
LOG.warn("Could not cleanup {}", setChannelMetadataResult, e);
System.out.printf("Could not cleanup {}", setChannelMetadataResult);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import org.jetbrains.annotations.Nullable;
import org.junit.After;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -48,7 +46,6 @@
import static org.junit.Assert.assertTrue;

public class ChannelMembersIT extends ObjectsApiBaseIT {
private static final Logger LOG = LoggerFactory.getLogger(ChannelMembersIT.class);
private static final String STATUS_01 = "myStatus01";
private static final String TYPE_01 = "myType01" + random();
private static final String TYPE_02 = "myType02" + random();
Expand Down Expand Up @@ -475,7 +472,7 @@ public void cleanUp() {
.sync();

} catch (Exception e) {
LOG.warn("Could not cleanup {}", createdMembers, e);
System.out.printf("Could not cleanup %s%n", createdMembers);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import org.apache.http.HttpStatus;
import org.junit.After;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -40,7 +38,6 @@
import static org.junit.Assert.assertNull;

public class MembershipIT extends ObjectsApiBaseIT {
private static final Logger LOG = LoggerFactory.getLogger(MembershipIT.class);
private static final String STATUS = "status";
private static final String CHANNEL = "channel";

Expand Down Expand Up @@ -453,7 +450,7 @@ public void cleanUp() {
pubNubUnderTest.removeMemberships(channelIds).sync();

} catch (Exception e) {
LOG.warn("Could not cleanup {}", createdMembership, e);
System.out.printf("Could not cleanup {}", createdMembership);
}
}
}
Expand Down
Loading
Loading