-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Swift 3.1 (SwiftMetricsDash not currently working) (#96)
* Fork agent core to support Swift 3.1 * rename header * rename header * move cpu header to include directory * move cpu header to include directory * update dependencies for 3.1 * update dependencies for 3.1 * Move cpuplugin.h * Move header files * Move header files * moved headers * moved headers * undo change for testing * install directory has changed * remove whitespace changes * Separate package.swift for 3.1 * Handle different install directories on 3.1/3.0 (#94) * install directory has changed * remove whitespace changes * Minor change to paths
- Loading branch information
1 parent
d01ffd0
commit 299065a
Showing
218 changed files
with
52,350 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Copyright IBM Corporation 2017 | ||
* | ||
* 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. | ||
**/ | ||
|
||
import PackageDescription | ||
|
||
#if os(Linux) | ||
let excludePortDir = "Sources/agentcore/ibmras/common/port/osx" | ||
#else | ||
let excludePortDir = "Sources/agentcore/ibmras/common/port/linux" | ||
#endif | ||
|
||
let package = Package( | ||
name: "SwiftMetrics", | ||
targets: [ | ||
Target(name: "SwiftMetrics", dependencies: [.Target(name: "agentcore"), | ||
.Target(name: "cpuplugin"), | ||
.Target(name: "envplugin"), | ||
.Target(name: "memplugin"), | ||
.Target(name: "hcapiplugin")]), | ||
Target(name: "SwiftMetricsKitura", dependencies: ["SwiftMetrics"]), | ||
Target(name: "SwiftMetricsBluemix", dependencies: ["SwiftMetricsKitura"]), | ||
Target(name: "SwiftMetricsDash", dependencies: ["SwiftMetricsBluemix"]), | ||
Target(name: "mqttplugin", dependencies: [.Target(name: "paho"), | ||
.Target(name: "agentcore")]), | ||
Target(name: "cpuplugin", dependencies: [.Target(name: "agentcore")]), | ||
Target(name: "envplugin", dependencies: [.Target(name: "agentcore")]), | ||
Target(name: "memplugin", dependencies: [.Target(name: "agentcore")]), | ||
Target(name: "hcapiplugin", dependencies: [.Target(name: "agentcore")]) | ||
], | ||
dependencies: [ | ||
.Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 7), | ||
.Package(url: "https://github.com/IBM-Swift/Kitura-WebSocket.git", majorVersion: 0, minor: 8), | ||
.Package(url: "https://github.com/IBM-Swift/Kitura-Request.git", majorVersion: 0, minor: 8), | ||
.Package(url: "https://github.com/IBM-Swift/CloudConfiguration.git", majorVersion: 2) | ||
], | ||
exclude: [ "Sources/agentcore/ibmras/common/port/aix", | ||
"Sources/agentcore/ibmras/common/port/windows", | ||
"Sources/agentcore/ibmras/common/data", | ||
"Sources/agentcore/ibmras/common/util/memUtils.cpp", | ||
"Sources/ostreamplugin", | ||
"Sources/paho/Windows Build", | ||
"Sources/paho/build", | ||
"Sources/paho/doc", | ||
"Sources/paho/test", | ||
"Sources/paho/src/MQTTClient.c", | ||
"Sources/paho/src/MQTTVersion.c", | ||
"Sources/paho/src/SSLSocket.c", | ||
"Sources/paho/src/samples", | ||
excludePortDir | ||
] | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/******************************************************************************* | ||
* Copyright 2016 IBM Corp. | ||
* | ||
* 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. | ||
*******************************************************************************/ | ||
|
||
|
||
#include <iostream> | ||
#include <cstdarg> | ||
#include <cstdio> | ||
#include <string> | ||
|
||
#include "LogManager.h" | ||
|
||
|
||
#if defined(_WINDOWS) | ||
#define VPRINT vsprintf_s | ||
#else | ||
#define VPRINT vsprintf | ||
#endif | ||
|
||
extern "C" { | ||
|
||
DECL void* ibmras_common_LogManager_getLogger(const char* name) { | ||
return (void*) ibmras::common::LogManager::getLogger(name); | ||
} | ||
} | ||
|
||
namespace ibmras { | ||
namespace common { | ||
|
||
LogManager* LogManager::instance = NULL; | ||
|
||
LOCAL_LOGGER_CALLBACK LogManager::localLogFunc = NULL; | ||
|
||
LogManager::LogManager() : | ||
level(info), localLog(true), lock(NULL) { | ||
/* do not create a lock in the constructor as it will create a loop with the logging in the port library */ | ||
} | ||
|
||
|
||
void LogManager::processMsg(const std::string &msg) { | ||
|
||
if (localLog) { | ||
/* local logging is overriding */ | ||
if (localLogFunc) { | ||
localLogFunc(msg); | ||
} else { | ||
std::cerr << msg << '\n'; | ||
std::cerr.flush(); | ||
} | ||
return; | ||
} | ||
|
||
} | ||
|
||
void LogManager::msgHandler(const std::string &message, loggingLevel level, | ||
Logger* logger) { | ||
|
||
/* logger level has priority over log manager level (which should be considered a default level */ | ||
if ((logger->level >= level) || (instance->level >= level)) { | ||
instance->processMsg(message); | ||
} | ||
} | ||
|
||
void LogManager::setLevel(loggingLevel newlevel) { | ||
LogManager::level = newlevel; | ||
for (std::vector<Logger*>::iterator i = loggers.begin(); i != loggers.end(); | ||
++i) { | ||
if ((*i)->level <= level) { | ||
(*i)->level = level; | ||
} | ||
} | ||
} | ||
|
||
void LogManager::setLevel(const std::string &name, loggingLevel newlevel) { | ||
if (name.compare("level") == 0) { | ||
setLevel(newlevel); | ||
} else { | ||
Logger* logger = getLogger(name); | ||
if (level > newlevel) { | ||
logger->level = level; | ||
} else { | ||
logger->level = newlevel; | ||
} | ||
logger->debugLevel = newlevel; | ||
} | ||
} | ||
|
||
LogManager* LogManager::getInstance() { | ||
if (!instance) { | ||
instance = new LogManager; | ||
instance->lock = new ibmras::common::port::Lock; | ||
} | ||
return instance; | ||
} | ||
|
||
Logger* LogManager::getLogger(const std::string &name) { | ||
LogManager* instance = getInstance(); | ||
Logger* logger = instance->findLogger(name); | ||
if (!logger) { /* logger not found so need to create a new instance and return that */ | ||
logger = new Logger(name, LogManager::msgHandler); | ||
instance->loggers.push_back(logger); | ||
} | ||
|
||
return logger; | ||
} | ||
|
||
void LogManager::setLevel(const std::string& name, const std::string& value) { | ||
loggingLevel lev = none; | ||
if (value.compare("warning") == 0) { | ||
lev = warning; | ||
} else if (value.compare("info") == 0) { | ||
lev = info; | ||
} else if (value.compare("fine") == 0) { | ||
lev = fine; | ||
} else if (value.compare("finest") == 0) { | ||
lev = finest; | ||
} else if (value.compare("debug") == 0) { | ||
lev = debug; | ||
} else { | ||
lev = none; | ||
} | ||
setLevel(name, lev); | ||
} | ||
|
||
Logger* LogManager::findLogger(const std::string &name) { | ||
|
||
for (std::vector<Logger*>::iterator i = loggers.begin(); i != loggers.end(); | ||
++i) { | ||
if ((*i)->component == name) { | ||
return (*i); | ||
} | ||
} | ||
return NULL; /* no match found */ | ||
} | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.