Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMOB-9306: Blackberry: add a universal logging mechanism for tibb #85

Merged
merged 5 commits into from Jun 29, 2012

Conversation

dlifshitz-maca
Copy link

Reviewers: David C, Harut

[Issues Fixed]
TIMOB-9306: Blackberry: add a universal logging mechanism for tibb

[Added]
NativeLoggerInterface.h
NativeLoggerObject.cpp
NativeLoggerObject.h
NativeLoggerWorker.cpp
NativeLoggerWorker.h
TiLogger.cpp
TiLogger.h

[Changes]
NativeAbstractTextControlObject.cpp
- switched to use N_DEBUG

NativeObject.h
- added N_TYPE_LOGGER
- removed old Ti_DEBUG

NativeObjectFactory.cpp
- added N_TYPE_LOGGER

TiUITableView.cpp
- switched to use Ti_DEBUG

TitaniumRuntime.cpp
- initialize TiLogger

[Tests]
Test 1: Use logger
1) Put some Ti_DEBUG and N_DEBUG statements in the code that will be run
2) Build tibb and verify there are no errors
3) Create, build, and run a new project
4) Verify the logging statements are in the app's log and are not intermingled

[Issues Fixed]
TIMOB-9306: Blackberry: add a universal logging mechanism for tibb

[Added]
NativeLoggerInterface.h
NativeLoggerObject.cpp
NativeLoggerObject.h
NativeLoggerWorker.cpp
NativeLoggerWorker.h
TiLogger.cpp
TiLogger.h

[Changes]
NativeAbstractTextControlObject.cpp
- switched to use N_DEBUG

NativeObject.h
- added N_TYPE_LOGGER
- removed old Ti_DEBUG

NativeObjectFactory.cpp
- added N_TYPE_LOGGER

TiUITableView.cpp
- switched to use Ti_DEBUG

TitaniumRuntime.cpp
- initialize TiLogger

[Tests]
Test 1: Use logger
1) Put some Ti_DEBUG and N_DEBUG statements in the code that will be run
2) Build tibb and verify there are no errors
3) Create, build, and run a new project
4) Verify the logging statements are in the app's log and are not intermingled

void TiLogger::log(std::string msg)
{
nativeLogger_->log(msg.c_str());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please check the pointer for null-ness

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If nativeLogger_ is null then you didn't call initialize() first or the factory is broken so a crash is appropriate.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the initialize is not called, I would prefer to miss logs (by checking against null-ness) rather than to make app crash

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, in the case it makes more sense to crash.

@Harutyun
Copy link

reviewed

Disables copy ctor and assignment operator, plus added comment.
@dlifshitz-maca
Copy link
Author

Updated patch

TiLogger(const TiLogger&);
TiLogger& operator=(const TiLogger&);

static NativeLoggerInterface* nativeLogger_;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should have a s_ prefix for static

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jpl-mac
Copy link

jpl-mac commented Jun 26, 2012

The logger should allow for TAGS (INFO, DEBUG, WARNING, ERROR, INTERNAL) logged in a way that makes them consistant so the logs can be filtered on them.

Could have a X_LOG that does what X_DEBUG currently does and take a TAG/severity param and have a MACRO for each of the TAGS (X_INFO, X_DEBUG, X_WARNING, X_ERROR, X_INTERNAL) so we don't have to specify the tag as a param


void NativeLoggerWorker::log(const QString& t)
{
fprintf(stderr, "%s", t.toStdString().c_str());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all logs errors? Can we have log flags where some logs go to stderr, some go to stdout, and some are stored in a file? This would be useful for testing release versions of the software where stderr and stdout would not be visible.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why stdout would be appropriate since these aren't outputs resulting from running the app, they're just logs. I don't think it makes a difference though because I see the logs in QDE and the logs/log file on the device. In other words, stdout and stderr both seem to go to the same places.

@dcampbell-macadamian
Copy link

reviewed

@dcampbell-macadamian
Copy link

approved

@Harutyun
Copy link

Approved

Changed to use streams instead for easier appending
Added tagged macros
Changed naming of s_nativeLogger and TI_DEBUG
@dlifshitz-maca
Copy link
Author

@jpl-mac I've added the tagged macros and also changed it to use streams since it's able to handle more things than std::string's + operator.

@dlifshitz-maca
Copy link
Author

Updated patch

@jpl-mac
Copy link

jpl-mac commented Jun 28, 2012

Thanks David, could you use this opportunity to also move the debug strings from NativeAbstractTextControlObject.cpp to TiMessageStrings or a native equivalent?

[Added]
NativeMessageStrings.cpp
NativeMessageStrings.h

[Changed]
Moved debug strings to central location
Removed unused function TitaniumRuntime::Log
@dlifshitz-maca
Copy link
Author

Updated patch: moved debug strings to central location

@jpl-mac
Copy link

jpl-mac commented Jun 29, 2012

Thanks David

Conflicts:
	blackberry/tibb/NativeObjectFactory.cpp
	blackberry/tibb/NativeStringInterface.cpp
	blackberry/tibb/TiMessageStrings.h
	blackberry/tibb/TiRootObject.cpp
dlifshitz-maca added a commit that referenced this pull request Jun 29, 2012
TIMOB-9306: Blackberry: add a universal logging mechanism for tibb

[Issues Fixed]
TIMOB-9306: Blackberry: add a universal logging mechanism for tibb

[Added]
NativeLoggerInterface.h
NativeLoggerObject.cpp
NativeLoggerObject.h
NativeLoggerWorker.cpp
NativeLoggerWorker.h
NativeMessageStrings.cpp
NativeMessageStrings.h
TiLogger.cpp
TiLogger.h

[Changes]
NativeAbstractTextControlObject.cpp
- switched to use N_DEBUG

NativeObject.h
- added N_TYPE_LOGGER
- removed old Ti_DEBUG

NativeObjectFactory.cpp
- added N_TYPE_LOGGER

TiUITableView.cpp
- switched to use Ti_DEBUG

TitaniumRuntime.cpp
- initialize TiLogger

Moved debug strings to central location
Removed unused function TitaniumRuntime::Log
Also moved the Native strings into NativeMessageStrings.h

[Tests]
Test 1: Use logger
1) Put some Ti_DEBUG and N_DEBUG statements in the code that will be run
2) Build tibb and verify there are no errors
3) Create, build, and run a new project
4) Verify the logging statements are in the app's log and are not intermingled
@dlifshitz-maca dlifshitz-maca merged commit 71dec25 into Macadamian:blackberry Jun 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants