Skip to content

Commit

Permalink
Logging does not work if written in lowercase(hazelcast.logging.level…
Browse files Browse the repository at this point in the history
…) [API-1740] (hazelcast#1432)

* Logging does not work if written in lowercase(hazelcast.logging.level) [API-1740]
  • Loading branch information
harunalpak authored and srknzl committed Mar 24, 2023
1 parent 1c2d4b9 commit 842a7b8
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DOCUMENTATION.md
Expand Up @@ -654,7 +654,7 @@ The following is the list of all client properties in alphabetical order.
| hazelcast.discovery.public.ip.enabled | null(detection enabled) | boolean or null | When set to `true`, the client will assume that it needs to use public IP addresses reported by members. When set to `false`, the client will always use private addresses reported by members. If it is `null`, the client will try to infer how the discovery mechanism should be based on the reachability of the members. This inference is not %100 reliable and may result in false negatives. |
| hazelcast.invalidation.max.tolerated.miss.count | 10 | number | If missed invalidation count is bigger than this value, relevant cached data in a Near Cache will be made unreachable. |
| hazelcast.invalidation.reconciliation.interval.seconds | 60 | number | Period of the task that scans cluster members to compare generated invalidation events with the received ones from the client Near Cache. |
| hazelcast.logging.level | INFO | string | Logging level. Can be one of `OFF`, `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`. |
| hazelcast.logging.level | INFO | string | Logging level. Can be one of `OFF`, `ERROR`, `WARN`, `INFO`, `DEBUG`, `TRACE`. You can also use lowercase characters ( `debug`, `warn`, `info` etc.) because this property is case insensitive. |

# 4. Serialization

Expand Down
32 changes: 32 additions & 0 deletions code_samples/logging_level_sample.js
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2008-2022, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';

const { Client } = require('hazelcast-client');

// This sample code demonstrates configuring logging level. We don't need to do any operations.
(async () => {
const client = await Client.newHazelcastClient({
properties: {
'hazelcast.logging.level': 'DeBuG' // this property value is case-insensitive
}
});
await client.shutdown();
})().catch(err => {
console.error('Error occurred:', err);
process.exit(1);
});

2 changes: 1 addition & 1 deletion src/util/Util.ts
Expand Up @@ -69,7 +69,7 @@ export function shuffleArray<T>(array: T[]): void {

/** @internal */
export function enumFromString<T>(enumType: any, value: string): T {
return enumType[value];
return enumType[value.toUpperCase()];
}

/** @internal */
Expand Down
4 changes: 3 additions & 1 deletion test/unit/config/ConfigBuilderTest.js
Expand Up @@ -422,7 +422,9 @@ describe('ConfigBuilderValidationTest', function () {
},
{
property: 'hazelcast.logging.level',
validValues: ['OFF', 'ERROR', 'WARN', 'INFO', 'DEBUG', 'TRACE'],
validValues: ['OFF', 'ERROR', 'WARN', 'INFO', 'DEBUG', 'TRACE',
'OfF', 'ErRoR', 'WarN', 'iNfO', 'DeBuG', 'TrAcE',
'off', 'error', 'warn', 'info', 'debug', 'trace'],
invalidValues: [1, 1.11, null, undefined, [], {}, true, 'someOtherString']
},
{
Expand Down
4 changes: 2 additions & 2 deletions test/unit/discovery/HazelcastCloudProviderTest.js
Expand Up @@ -19,7 +19,7 @@ const { expect } = require('chai');
const sinon = require('sinon');
const sandbox = sinon.createSandbox();

const { LogLevel, IllegalStateError } = require('../../../');
const { IllegalStateError } = require('../../../');
const { LoggingService } = require('../../../lib/logging/LoggingService');
const { AddressImpl } = require('../../../lib/core/Address');
const { HazelcastCloudAddressProvider } = require('../../../lib/discovery/HazelcastCloudAddressProvider');
Expand All @@ -37,7 +37,7 @@ describe('HazelcastCloudProviderTest', function () {
});

beforeEach(function () {
const logger = new LoggingService(null, LogLevel.INFO).getLogger();
const logger = new LoggingService(null, 'INFO').getLogger();
hazelcastCloudDiscovery = new HazelcastCloudDiscovery();
sandbox.stub(HazelcastCloudDiscovery.prototype, 'discoverNodes')
.callsFake(() => Promise.resolve(expectedAddresses));
Expand Down

0 comments on commit 842a7b8

Please sign in to comment.