/src/logging-log4cxx/src/main/cpp/configurator.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
3 | | * contributor license agreements. See the NOTICE file distributed with |
4 | | * this work for additional information regarding copyright ownership. |
5 | | * The ASF licenses this file to You under the Apache License, Version 2.0 |
6 | | * (the "License"); you may not use this file except in compliance with |
7 | | * the License. You may obtain a copy of the License at |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | */ |
17 | | |
18 | | #include <log4cxx/logstring.h> |
19 | | #include <log4cxx/spi/configurator.h> |
20 | | #include <assert.h> |
21 | | #include <log4cxx/logger.h> |
22 | | #include <log4cxx/helpers/singletonholder.h> |
23 | | #include <log4cxx/helpers/system.h> |
24 | | |
25 | | #if !defined(LOG4CXX) |
26 | | #define LOG4CXX 1 |
27 | | #endif |
28 | | #include <log4cxx/helpers/aprinitializer.h> |
29 | | |
30 | | using namespace LOG4CXX_NS; |
31 | | using namespace LOG4CXX_NS::spi; |
32 | | |
33 | | IMPLEMENT_LOG4CXX_OBJECT(Configurator) |
34 | | |
35 | | |
36 | | namespace |
37 | | { |
38 | | struct ConfiguratorTag {}; |
39 | | using ConfiguratorProperties = std::pair<ConfiguratorTag, helpers::Properties>; |
40 | | |
41 | | ConfiguratorProperties& getInstance() |
42 | 0 | { |
43 | 0 | using ConfiguratorObject = helpers::SingletonHolder<ConfiguratorProperties>; |
44 | 0 | auto result = helpers::APRInitializer::getOrAddUnique<ConfiguratorObject> |
45 | 0 | ( []() -> helpers::ObjectPtr |
46 | 0 | { return std::make_shared<ConfiguratorObject>(); } |
47 | 0 | ); |
48 | 0 | return result->value(); |
49 | 0 | } |
50 | | } |
51 | | |
52 | | Configurator::Configurator() |
53 | 0 | { |
54 | 0 | } |
55 | | |
56 | | helpers::Properties& Configurator::properties() |
57 | 0 | { |
58 | 0 | auto& result = getInstance().second; |
59 | 0 | if (result.isEmpty()) |
60 | 0 | helpers::System::addProgramFilePathComponents(result); |
61 | 0 | return result; |
62 | 0 | } |