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

Fix device logs #4163

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Fix device logs #4163

wants to merge 7 commits into from

Conversation

nnngrach
Copy link
Contributor

@nnngrach nnngrach commented Dec 2, 2024

Founded some trouble with writing log file on device.

  • Deleted old log in random order. Sometimes deleted the latest log. Fixed.

  • it didn't write many logs to the file. From Swift and C++ by example. Fixed.

Before:

Objc NSLog	  |		2024-12-02 22:11:10.250 OsmAnd Maps[9719:1258334]  !!!!! Objc NSLog SeneDelegate AppLaunchEventStart

----------


After:

Objc NSLog	  |		2024-12-02 22:02:19.519 OsmAnd Maps[9678:1252484]  !!!!! Objc NSLog SceneDelegate AppLaunchEventStart

Objc OALog	  |		INFO: 2024-12-02 22:02:19.519  [MainTread 259]   !!!!! Objc OALog SceneDelegate AppLaunchEventStart

Swift print()      |		!!!!! SwiftPrint addWidgetLayerDecorator

Swift OALog	  |		INFO: 2024-12-02 22:31:32.054  [MainTread 259]   !!!!! Swift OALog() addWidgetLayerDecorator

cpp printp	  |		!!!!! cpp printp MapRenderer::setZoom()

cpp std::cout     |		!!!!! cpp std::cout MapRenderer::setZoom()

----------

old Dec 02, 2024 22:11.log
new Dec 02, 2024 22:02:19.log

  • Added seconds to file name. Without this, if the user starts the application twice in a minute, the second file will overwrite the first.

  • Improved New OALog version output. Now it prints more information about thread:

before:
OsmAnd Maps[9678:1252484]

after:
[MainTread 259]
[Tread 11779]
[Tread 12345 Background]
  • OALog now has option to show custom log level. Not only INFO.
OALog(@"Hello world")
INFO: 2024-12-02 22:02:19.519  [MainTread 259]  Hello world

OALogWithLevel(EOALogError, @"Hello world")
ERROR: 2024-12-02 22:02:19.519  [MainTread 259]  Hello world

levels:
EOALogVerbose,
EOALogDebug,
EOALogInfo,
EOALogWarning,
EOALogError
  • OALog now can be used from Swift. Just use the same syntax like usual.
    OALog("Hello world")

PS: most changes are in files
OALog.h
OALog.m
OsmAndAppImpl.mm
OALogWrapper.swift

@nnngrach nnngrach linked an issue Dec 3, 2024 that may be closed by this pull request
@@ -97,7 +97,7 @@ extension DashboardCarPlaySceneDelegate: CPTemplateApplicationDashboardSceneDele
}

func templateApplicationDashboardScene(_ templateApplicationDashboardScene: CPTemplateApplicationDashboardScene, didDisconnect dashboardController: CPDashboardController, from window: UIWindow) {
NSLog("[CarPlay] DashboardCarPlaySceneDelegate didDisconnect")
// OALog("[CarPlay] DashboardCarPlaySceneDelegate didDisconnect")
Copy link
Contributor

Choose a reason for hiding this comment

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

?

+ (NSString *) getFormattedTimestampByDate:(NSDate *)date
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
Copy link
Contributor

Choose a reason for hiding this comment

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

use lazy load for NSDateFormatter

return @"";
//most common format. don't write
//return @"Interactive";
Copy link
Contributor

Choose a reason for hiding this comment

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

?

{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"];
Copy link
Contributor

Choose a reason for hiding this comment

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

Use more precision SSSS

@@ -4072,15 +4072,15 @@ - (void) startProgress

- (void) updateProgress:(int)progress
{
//NSLog(@"Route calculation in progress: %d", progress);
//OALog(@"Route calculation in progress: %d", progress);
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

@@ -155,7 +156,7 @@ - (void)buildParameters:(NSString *)styleName
{
NSString *name = resolvedMapStyle->getStringById(p->getNameId()).toNSString();

//NSLog(@"name = %@ title = %@ decs = %@ category = %@", name, p->getTitle().toNSString(), p->getDescription().toNSString(), p->getCategory().toNSString());
//OALog(@"name = %@ title = %@ decs = %@ category = %@", name, p->getTitle().toNSString(), p->getDescription().toNSString(), p->getCategory().toNSString());
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

@@ -9,6 +9,7 @@
#import "OAOsmBugsDBHelper.h"
#import "OABackupHelper.h"


Copy link
Contributor

Choose a reason for hiding this comment

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

?

@@ -9,6 +9,7 @@
#import <XCTest/XCTest.h>
#import "OARouteProvider.h"
#import "OARouteCalculationParams.h"
#import "OALog.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

For the Test Target, do we definitely need to use file writing? OALog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decrease default min. zoom
2 participants