Bug? [CLOSED] No log information displayed

lemonisdead

Well-Known Member
Licensed User
Hello,
I am going crazy with a specific project : till this morning I can not see any logged information using Log or LogColor from services created using v5.02

I mean that : when I create a service with v5.02 and put Log("blabla") in Service_Start, I can see the service Start in the log window but not the sentence I've put.

I returned back to v4.30 and saw the logged information. After that I have mixed a module created with v4.30 and one created with v5.02. The one created with v5.02 didn't displayed the logged information.

I am turning crazy because it is hard to prove and to understand : I created a new project and mixed exactly some modules and it worked...
 

lemonisdead

Well-Known Member
Licensed User
Edit : Erel, I didn't want to disturb you by sending the project directly to you but if you could agree I would be glad to submit it to you as, I have checked all and I can not understand what happens (I won't export it but copy the whole folder : perhaps something in the sources)...
 

Jmu5667

Well-Known Member
Licensed User
Hi,

I am the same problems, however, here's a solution for you:

B4X:
Sub writelog(m As String)
   
   Dim s As OutputStream, b() As Byte  
   Dim TimeFormat, myTimeFormat As String
   
   Try
     ' // save existing time format
     TimeFormat = DateTime.TimeFormat
         
     myTimeFormat = "HH:mm:ss.SSS"
     ' // set date time format
     DateTime.TimeFormat = myTimeFormat
     ' // debugger logging
     Log(DateTime.Date(DateTime.Now) & " " & DateTime.time(DateTime.Now) & " - " & m)
     ' // create log data for file
     m = DateTime.Date(DateTime.Now) & " " & DateTime.time(DateTime.Now) & " - " & m & Chr(10) & Chr(13)
     ' // restore date time format
     DateTime.TimeFormat = TimeFormat
     
     b = m.GetBytes("UTF8")
     
     If File.ExternalWritable = False Then
       If File.Size(File.DirInternal, "yourappname.log") >= 1048576 Then
         File.Delete(File.DirInternal, "yourappname.log")
       End If
       s = File.OpenOutput(File.DirInternal, "yourappname.log", True)
       
     Else
       If File.Size(File.DirDefaultExternal, "yourappname.log") >= 1048576 Then
         File.Delete(File.DirDefaultExternal, "yourappname.log")
       End If
       s = File.OpenOutput(File.DirDefaultExternal,"yourappname.log", True)
     End If
     
     s.WriteBytes(b,0,b.Length -1)
     s.Flush
     s.close

     
   Catch
     Log("writelog, error - " & LastException.Message)
   End Try
     
   
End Sub
Also download https://play.google.com/store/apps/details?id=com.theolivetree.ftpserver from the playstore, and also install notepad++, https://notepad-plus-plus.org/.

I use this combination to get my logging information. I remember that android changed the way some log data is displayed so on some devices you dont get any. Notepad ++ will detect a change in the log file and update the view for you.

Hope this helps

John.
 

lemonisdead

Well-Known Member
Licensed User
Hello John,
Please forgive me if I don't know how to really thank you for your idea and the amount of useful information you provided. I am a bit stressed with that issue.
Your idea is more than useful but doesn't fix my problem : in fact I wonder if any code is executed. I mean that Writelog() works pretty well but, believe it or not, from the service I was talking about, nothing is... logged. OF course, other parts are logged correctly...

LogCat connected to: TA929004TS
--------- beginning of crash
--------- beginning of system
--------- beginning of main
** Service (core) Create **
** Service (core) Start **
core démarre
06/22/2015 14:33:08.357 - core démarre
** Service (core) Destroy **
** Service (core) Create **
** Service (core) Start **
core démarre
06/22/2015 14:33:13.633 - core démarre
** Service (core) Destroy **
** Service (core) Create **
** Service (core) Start **
core démarre
06/22/2015 14:33:18.766 - core démarre
** Service (core) Destroy **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (core) Create **
** Service (core) Start **
core démarre
06/22/2015 14:33:23.793 - core démarre
** Service (core) Destroy **
** Activity (main) Pause, UserClosed = true **~i:** Service (core) Create **
** Service (core) Start **
core démarre
06/22/2015 14:33:28.904 - core démarre
** Service (core) Destroy **
** Service (core) Create **
** Service (core) Start **
core démarre
06/22/2015 14:33:33.921 - core démarre
** Service (core) Destroy **
** Service (core) Create **
** Service (core) Start **
core démarre
06/22/2015 14:33:38.959 - core démarre
** Service (core) Destroy **
** Service (core) Create **
** Service (core) Start **
core démarre
06/22/2015 14:33:44.001 - core démarre
** Service (core) Destroy **
** Service (core) Create **
** Service (core) Start **
core démarre
06/22/2015 14:33:49.023 - core démarre
** Service (core) Destroy **
** Service (core) Create **
** Service (core) Start **
core démarre
06/22/2015 14:33:54.052 - core démarre
** Service (core) Destroy **
** Service (core) Create **
** Service (core) Start **
core démarre
06/22/2015 14:33:59.076 - core démarre
** Service (core) Destroy **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Service (switcher) Create **
** Service (switcher) Start **
** Service (switcher) Destroy **
** Service (switcher) Create **
** Service (switcher) Start **
** Service (switcher) Destroy **
** Service (s5) Create **
** Service (s5) Start **
** Service (s5) Destroy **
** Service (switcher) Create **
** Service (switcher) Start **
** Service (switcher) Destroy **
** Service (switcher) Create **
** Service (switcher) Start **
** Service (switcher) Destroy **
** Service (s5) Create **
** Service (s5) Start **
** Service (s5) Destroy **
** Service (switcher) Create **
** Service (switcher) Start **
** Service (switcher) Destroy **
** Service (switcher) Create **
** Service (switcher) Start **
** Service (switcher) Destroy **
** Service (switcher) Create **
** Service (switcher) Start **
** Service (switcher) Create **
** Service (s6) Create **
** Service (switcher) Start **
** Service (s6) Start **
** Service (switcher) Destroy **
** Service (s6) Destroy **
** Service (switcher) Destroy **
** Service (s6) Create **
** Service (s6) Start **
** Service (s6) Destroy **

Edit : I have noticed that the code is not updated in the generated apk (s6 service) and opened a question about
 
Last edited:

Jmu5667

Well-Known Member
Licensed User
Hello John,
Please forgive me if I don't know how to really thank you for your idea and the amount of useful information you provided. I am a bit stressed with that issue.
Your idea is more than useful but doesn't fix my problem : in fact I wonder if any code is executed. I mean that Writelog() works pretty well but, believe it or not, from the service I was talking about, nothing is... logged. OF course, other parts are logged correctly...

Ok. We will start at the beginning.

Create a module(mod_functions) and put the write log function into it.

In each service you you put the following code

B4X:
Sub Service_Create
   
   mod_functions.writelog("your_service_name(),Service_Create")
   
End Sub

Sub Service_Start (StartingIntent As Intent)

   mod_functions.writelog("your_service_name(),Service_Start")
  
   StopService("")
   
End Sub

Sub Service_Destroy
   
   mod_functions.writelog("your_service_name(),Service_Destroy")
   
End Sub
you will notice in the start service I stop the service. By doing this you can trace the operation on the service call without having any other code written. If you can do this for all your services and let me know how you get on please.

J.
 

lemonisdead

Well-Known Member
Licensed User
Hello Erel,
I am testing in "Release obfuscated" mode and directly connected to a real device via USB.
Sorry to repeat : the module created with the version 4.30 does print its log. I have took a look at the "java source" (in objects \ src) and the file does include the logging
B4X:
 //BA.debugLineNum = 26;BA.debugLine="LogColor(\"Idle\",Colors.Blue)";
anywheresoftware.b4a.keywords.Common.LogColor("Idle",anywheresoftware.b4a.keywords.Common.Colors.Blue);
I really don't understand what happens. Thanks for the confirmation about the compatibility between both versions too.
 
Top