History

Complete console.trace and added a testcases for all 13 functions.

NeetBhagat committed 9 years ago

Commit 9646eba1 parent 5c3242615 files · +204 −165Browse files

Showing the changes to libraries/script-engine/src/ConsoleScriptingInterface.h (1 of 15 files). Show all

Unified · Split

libraries/script-engine/src/ConsoleScriptingInterface.h+15−29
@@ -2,12 +2,14 @@ · 1 unmodified line
2// ConsoleScriptingInterface.h2// ConsoleScriptingInterface.h
3// libraries/script-engine/src3// libraries/script-engine/src
4//4//
5// Created by volansystech on 6/1/17.5// Created by NeetBhagat on 6/1/17.
6// Copyright 2014 High Fidelity, Inc.6// Copyright 2014 High Fidelity, Inc.
7//7//
8// ConsoleScriptingInterface is responsible to print log.8// ConsoleScriptingInterface is responsible for following functionality
9// using "console" object on debug Window and Logs/log file with proper tags.9// Printing logs with various tags and grouping on debug Window and Logs/log file.
10// Used in Javascripts file.10// Debugging functionalities like Timer start-end, assertion, trace.
11// To use these functionalities, use "console" object in Javascript files.
12// For examples please refer "scripts/developer/tests/consoleObjectTest.js"
11//13//
12// Distributed under the Apache License, Version 2.0.14// Distributed under the Apache License, Version 2.0.
13// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html15// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@@ -17,17 +19,13 @@ · 3 unmodified lines
17#ifndef hifi_ConsoleScriptingInterface_h19#ifndef hifi_ConsoleScriptingInterface_h
18#define hifi_ConsoleScriptingInterface_h20#define hifi_ConsoleScriptingInterface_h
19 21
20
21#include <QtCore/QObject>22#include <QtCore/QObject>
22#include <QtCore/QString>23#include <QtCore/QString>
23#include <QtScript/QScriptable>24#include <QtScript/QScriptable>
24#include <QHash>
25#include "EntityEditFilters.h"
26#include <QUrl>
27#include <QList>25#include <QList>
26#include <QHash>
28 27
29 28// Scriptable interface of "console" object. Used exclusively in the JavaScript API
30/// Scriptable interface of console object. Used exclusively in the JavaScript API
31class ConsoleScriptingInterface : public QObject, protected QScriptable {29class ConsoleScriptingInterface : public QObject, protected QScriptable {
32 Q_OBJECT30 Q_OBJECT
33public slots:31public slots:
@@ -38,29 +36,17 @@ public slots: · 4 unmodified lines
38 void error(QString message);36 void error(QString message);
39 void exception(QString message);37 void exception(QString message);
40 void time(QString labelName);38 void time(QString labelName);
41 void timeEnd(QString labelName); 39 void timeEnd(QString labelName);
42 void asserts(bool condition, QString message = "");40 void asserts(bool condition, QString message = "");
43 void trace();41 void trace();
44 void clear(); 42 void clear();
45 void group(QString groupName);43 void group(QString groupName);
46 void groupCollapsed(QString groupName); 44 void groupCollapsed(QString groupName);
47 void groupEnd(); 45 void groupEnd();
48 void consoleGroupLog(QString currentGroup, QString groupName);
49public:
50 QString secondsToString(qint64 seconds);
51 bool hasCorrectSyntax(QScriptProgram& program);
52 QString hadUncaughtExceptions(QScriptEngine& engine, QString& fileName);
53private:46private:
54 QHash<QString, QDateTime> _listOfTimeValues;47 QHash<QString, QDateTime> _timerDetails;
55 const qint64 DAY = 86400;48 QList<QString> _groupDetails;
56 const QString TIME_FORMAT = "yyyy-MM-dd HH:mm"; 49 void logGroupMessage(QString msg);
57 QString _selectedGroup;
58 const QString GROUP = "group";
59 const QString GROUPCOLLAPSED = "groupCollapse";
60 const QString GROUPEND = "groupEnd";
61 bool _isSameLevel = false;
62 QString _addSpace = "";
63 bool _isGroupEnd = true;
64};50};
65 51
66#endif // hifi_ConsoleScriptingInterface_h52#endif // hifi_ConsoleScriptingInterface_h