Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4e5cfa4
Added canLogAtLevel API in logging.
sima-zhu Dec 17, 2019
e6ad3c6
Update sdk/core/azure-core/src/main/java/com/azure/core/util/logging/…
sima-zhu Dec 17, 2019
19c6422
Update sdk/core/azure-core/src/main/java/com/azure/core/util/logging/…
sima-zhu Dec 17, 2019
9fc91ba
added parameterized tests for newly added API
sima-zhu Dec 17, 2019
21f1273
Merge branch 'canLogAtLevel' of https://github.com/sima-zhu/azure-sdk…
sima-zhu Dec 17, 2019
b8104d4
Fixed linting issue
sima-zhu Dec 17, 2019
210302c
Added string alias for log level and remove disable level.
sima-zhu Dec 18, 2019
6211513
Remove unused imports
sima-zhu Dec 18, 2019
d3b9fff
Remove extra helper methods
sima-zhu Dec 18, 2019
ec2c5b1
Remove extra helper methods
sima-zhu Dec 18, 2019
1399319
Make changes to JavaDoc.
sima-zhu Dec 18, 2019
15edb3d
Update sdk/core/azure-core/src/main/java/com/azure/core/util/logging/…
sima-zhu Dec 18, 2019
ceb458a
Change public methods private
sima-zhu Dec 18, 2019
c3d2f5b
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-java …
sima-zhu Dec 18, 2019
d441a04
Merge branch 'canLogAtLevel' of https://github.com/sima-zhu/azure-sdk…
sima-zhu Dec 18, 2019
f6ed817
Remove numeric, added map at initial
sima-zhu Dec 18, 2019
12d82d9
Make changes to name
sima-zhu Dec 18, 2019
9235b21
Fixed linting issue
sima-zhu Dec 18, 2019
96b9133
Fixed null value bugs
sima-zhu Dec 18, 2019
a2862b7
Added more null gating for logging
sima-zhu Dec 18, 2019
5334113
Make changes to add NOT_SET, throw error for invalid log level
sima-zhu Dec 18, 2019
1ac0104
Fixed some changes
sima-zhu Dec 18, 2019
13de5d8
Fixed linting issue
sima-zhu Dec 18, 2019
dd01e2f
Added more test cases
sima-zhu Dec 18, 2019
0f20193
Rename the tests
sima-zhu Dec 18, 2019
18c16cb
Some improvement
sima-zhu Dec 20, 2019
950b427
Remove the testing changes
sima-zhu Dec 20, 2019
2e35662
Fixed typo
sima-zhu Dec 20, 2019
da565b3
added more description in javadoc
sima-zhu Dec 23, 2019
81b0a34
Update LogLevel.java
sima-zhu Jan 6, 2020
d00b87f
Update LogLevel.java
sima-zhu Jan 6, 2020
21a51b4
Update LogLevel.java
sima-zhu Jan 6, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ private RuntimeException logException(RuntimeException runtimeException, LogLeve
return runtimeException;
}

/*
* Determines if the environment and logger support logging at the given log level.
*
* @param logLevel Logging level for the log message.
Comment thread
sima-zhu marked this conversation as resolved.
Outdated
* @return Flag indicating if logger are configured to support logging at the given log level.
Comment thread
sima-zhu marked this conversation as resolved.
Outdated
*/
public boolean canLogAtLevel(LogLevel logLevel) {
Comment thread
alzimmermsft marked this conversation as resolved.
LogLevel environmentLoggingLevel = getEnvironmentLoggingLevel();
return canLogAtLevel(logLevel, environmentLoggingLevel);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need to create a local variable here - just call getEnvironmentLoggingLevel() directly in the second line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

}

/*
* Performs the logging.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package com.azure.core.util.logging;

import com.azure.core.implementation.LogLevel;
import com.azure.core.util.Configuration;
import com.azure.core.util.CoreUtils;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -276,6 +277,18 @@ public void logExceptionAsErrorStackTrace() {
assertTrue(logValues.contains(runtimeException.getStackTrace()[0].toString()));
}

@Test
Comment thread
alzimmermsft marked this conversation as resolved.
Outdated
public void canLogAtLevelTrue(){
setupLogLevel(2);
assertTrue(new ClientLogger(ClientLoggerTests.class).canLogAtLevel(LogLevel.ERROR));
}

@Test
public void canLogAtLevelFalse(){
setupLogLevel(2);
assertFalse(new ClientLogger(ClientLoggerTests.class).canLogAtLevel(LogLevel.VERBOSE));
}

private String setupLogLevel(int logLevelToSet) {
String originalLogLevel = Configuration.getGlobalConfiguration().get(Configuration.PROPERTY_AZURE_CLOUD);
System.setProperty(Configuration.PROPERTY_AZURE_LOG_LEVEL, Integer.toString(logLevelToSet));
Expand Down