console.log("Coolant level is low, check for coolant leak");
console.warn("Antimatter containment fields fluctuating");
console.error("Warp core ejection in progress");
sap.Logger.getLogEntries()
sap.Logger.emailLog()
sap.Logger.upload()
sap.Logger.setLogLevel(sap.Logger.ERROR)
cordova plugin add kapsel-plugin-logger --searchpath %KAPSEL_HOME%/plugins
or
cordova plugin add kapsel-plugin-logger --searchpath $KAPSEL_HOME/plugins
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="serverContext.js"></script>
<script>
applicationContext = null;
window.onerror = onError;
function onError(msg, url, line) {
var idx = url.lastIndexOf("/");
var file = "unknown";
if (idx > -1) {
file = url.substring(idx + 1);
}
alert("An error occurred in " + file + " (at line # " + line + "): " + msg);
return false; //suppressErrorAlert;
}
function init() {
if (navigator.notification) { // Override default HTML alert with native dialog. alert is not supported on Windows
window.alert = navigator.notification.alert;
}
getLogLevel();
sap.Logon.init(function() { }, function() { alert("Logon Failed"); }, appId, context);
}
function logMessage() {
var logMessage = document.getElementById("logMessage").value;
var level = document.getElementById("level").value;
if (level === "DEBUG") {
console.debug(logMessage); //could also use sap.Logger.debug
}
else if (level === "INFO") {
console.info(logMessage);
}
else if (level === "WARN") {
console.warn(logMessage);
}
else if (level === "ERROR") {
console.error(logMessage);
}
}
function uploadLog() {
sap.Logger.upload(function() {
alert("Upload Successful");
}, function(e) {
alert("Upload Failed. Status: " + e.statusCode + ", Message: " + e.statusMessage);
});
}
function setLogLevel(logLevel) {
sap.Logger.setLogLevel(logLevel);
console.log("Log level set to " + logLevel);
document.getElementById("span1").innerHTML = logLevel;
}
function getLogLevel() {
sap.Logger.getLogLevel(getLogLevelSuccess, getLogLevelFailure);
}
function getLogLevelSuccess(level) {
document.getElementById("span1").innerHTML = level;
console.log("Log Level is " + level);
}
function getLogLevelFailure(error) {
alert("Failure in getting log level" + JSON.stringify(error));
}
function clearLogSuccess() {
console.log("Log has been cleared");
}
function clearLogError(error) {
alert("Failure in clearing log. " + JSON.stringify(error));
}
function emailLogSuccess() {
console.log("Log emailed successfully");
}
function emailLogError(error) {
alert("Failure in emailing log. " + JSON.stringify(error));
}
function getLogEntriesSuccess(logEntries) {
var stringToShow = "";
var logArray;
if (device.platform == "windows") {
logArray = logEntries.split("\n");
if (logArray.length > 0) {
for (var i = 0; i < logArray.length; i++) {
stringToShow += logArray[i] + "\n";
}
}
}
else if (device.platform == "iOS") {
logArray = logEntries.split("\n");
if (logArray.length > 0) {
for (var i = 0; i < logArray.length; i++) {
logLineEntries = logArray[i].split(" ");
for (var j = 7; j < logLineEntries.length; j++) {
stringToShow += logLineEntries[j] + " ";
}
stringToShow = stringToShow + "\n";
}
}
}
else { //Android
logArray = logEntries.split('#');
if (logArray.length > 0) {
var numOfMessages = parseInt(logArray.length / 15);
for (var i = 0; i < numOfMessages; i++) {
stringToShow += logArray[i * 15 + 1] + ": " + logArray[i * 15 + 3] + ": " + logArray[i * 15 + 14] + "\n";
}
}
}
alert(stringToShow);
console.log("EventLogging: Device Log follows " + stringToShow);
}
function getLogEntriesError(error) {
alert("Failure in getting log entries. " + JSON.stringify(error));
}
document.addEventListener("deviceready", init, false);
</script>
</head>
<body>
<h1>Logger Sample</h1>
<button onclick="sap.Logger.clearLog(clearLogSuccess, clearLogError)">Clear the Log</button><br><br>
Application Log Level: <span id="span1"></span><br><br>
Set Application Log Level: <button onclick="setLogLevel(sap.Logger.DEBUG)">DEBUG</button><button onclick="setLogLevel(sap.Logger.INFO)">INFO</button><button onclick="setLogLevel(sap.Logger.WARN)">WARN</button><button onclick="setLogLevel(sap.Logger.ERROR)">ERROR</button><br><br>
Log Message at Level:<select id="level"><option>DEBUG</option><option>INFO</option><option>WARN</option><option>ERROR</option></select><br><br>
Log a message <input type="text" id="logMessage" value="Logged using console.log"><br>
<button id="log" onclick="logMessage()">Log</button><br><br>
Messages logged using sap.Logger can be viewed on the device.<br>
<button id="getLogEntries" onclick="sap.Logger.getLogEntries(getLogEntriesSuccess, getLogEntriesError)">View Log</button><br><br>
Messages logged using sap.Logger can be sent via email.<br>
<button id="email" onclick="sap.Logger.emailLog('helpdesk@mycompany.com','The log','Please see the attached log.', emailLogSuccess, emailLogError)">Email Log</button><br><br>
Messages logged using sap.Logger can be uploaded to the SMP 3.0 server.<br>
<button id="upload" onclick="uploadLog()">Upload Log</button><br><br>
</body>
</html>
cordova run android
or
cordova run windows -- --archs=x64
or
cordova run windows --device -- --archs=arm --phone
or
cordova run ios
C:\Kapsel_Projects\KapselGSDemo\platforms\android\assets\sap-supportability.properties
clientLogManager=com.sap.smp.client.supportability.log.ClientLogManagerImpl
e2eTraceManager=com.sap.smp.client.supportability.e2e.E2ETraceManagerImpl
file_size=102400
file_count=10
file_age=604800000
adb root
adb shell
cd data\data\com.kapsel.gs\files
ls -l
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
10 | |
10 | |
9 | |
8 | |
8 | |
6 | |
6 | |
5 | |
5 |