Flutter Logging - A Guide on How to Use it Effectively

Поділитися
Вставка
  • Опубліковано 5 лип 2024
  • Written tutorial: www.filledstacks.com/post/flu...
    Tutorial Source: github.com/FilledStacks/flutt...
    Code to download: firebasestorage.googleapis.co...
  • Наука та технологія

КОМЕНТАРІ • 61

  • @jonathan10543
    @jonathan10543 5 років тому +1

    Thanks! I've been struggling with debugging. The written guide and this video make logging in Flutter crystal clear!

    • @FilledStacks
      @FilledStacks  5 років тому

      Awesome man!! That's exactly what I was hoping for. I'm happy to have helped :)

  • @narcodico
    @narcodico 5 років тому +11

    As IceCube once said of logging: Warn yo self, before you wreck yo self!

    • @FilledStacks
      @FilledStacks  5 років тому +1

      hahaha, he does often say that 😅 Always here so early. You da best! 🤩

    • @narcodico
      @narcodico 5 років тому +1

      @@FilledStacks Don't mind me, just passing through, hunting for quality flutter content, it just so happens that you have it 🙃

    • @FilledStacks
      @FilledStacks  5 років тому

      🙌 ☺️

  • @finzaikofin
    @finzaikofin 5 років тому

    Thanks I much learned from your blog and this channel. Awesome!
    I'm waiting tutorial for handle paging or infinite scroll over rest api using provider/bloc with future builder.

    • @FilledStacks
      @FilledStacks  5 років тому +2

      Awesome man! I might do a video on that but I won't use a Future builder. The model would collect the data and concatenate the list. We'll call notifyListeners when the list has been updated.

  • @martinharris4416
    @martinharris4416 4 роки тому +3

    No one :
    FilledStacks : *Lets create a new file*

  • @getmmg
    @getmmg 5 років тому

    Thanks a lot, very helpful package and wonderful explanation as ever. I would really like you to do a video on setting up multiple flavors of the app in flutter.

    • @FilledStacks
      @FilledStacks  5 років тому

      Thanks for the feedback. It's not something very common at the moment and there are some community articles on it already (cogitas.net/creating-flavors-of-a-flutter-app/) I usually do branding through my source control using branches per product flavour instead of cluttering the code with all that logic.

  • @dilipghawade6651
    @dilipghawade6651 5 років тому

    Really helpful thanks

  • @kambizshahri1504
    @kambizshahri1504 4 роки тому +1

    Sho', really good stuff here...thank you...maybe one suggestion would be to contribute to the Flutter or the Dart logger and provide your logger flavour as a solid implementation so the whole community could profit from it. Just a suggestion. One other suggestion would be for a dependecy injection for logging of the entry to a function...hardcoding it would be a maintenance overhead especially if the codebase is large. Not sure about the latter, since I am a Go/Java programmer and new to Dart/Flutter. In other words it would be great to be able to configure a Dependency Injection of a logger so that one could trace the calls. Even better would be to be able to switch it on and off again. Lastly, for Production code, what is the overhead for logging...okay i think i have veered a little off topic here.

    • @FilledStacks
      @FilledStacks  4 роки тому +1

      Thanks, happy you found some value in it. The most I would probably do is create a package that contains the 6 lines of code for the logger as an extension but I don't think they'd accept my specific logging format as a default option. There are definitely ways to automatically log some stuff. Maybe when I get some time I can write up the code for that and release it as a LogPrinter extension package.

  • @paulbaker2499
    @paulbaker2499 4 роки тому

    Great video. Reminds me of Log4J and how cool that was at creating your own 'pretty printers'. One question - on VS CODE, how did you get your colours to display - I'm getting ascii codes being shown in the debug console so I'm guessing it might be a special installed font you are using ?

    • @FilledStacks
      @FilledStacks  4 роки тому

      Hi Stella, thanks for the feedback. I will assume you're on a Mac. After releasing the video i realised that many devs are not seeing the colors show up and they were all on Mac. There's been issues filed on the repo. Or someone contacted the dev, can't remember which way it went but he's working on it. If you're not on Mac then ignore all that 😅 I didn't install anything special. Default powershell terminal shows the colors for me.

  • @alivevilaalivevila6665
    @alivevilaalivevila6665 5 років тому

    thanks for the video, coming from fireship. this channel worth subscribing.

    • @FilledStacks
      @FilledStacks  5 років тому +1

      Thanks a lot. That's a huge compliment man. Much appreciated, I'm a big fan of the Fireship videos myself.

  • @oliverbytes
    @oliverbytes 4 роки тому +1

    I'm starting to like your channel. very very good contents and lots of advanced topics.. Do you have an example of properly using Logger for Errors? I wish you have a snippet for it

    • @FilledStacks
      @FilledStacks  4 роки тому

      I do have a Logging tutorial. It gives a run down of when to log and what to log to make sense of any error that happens in the code.

  • @camillo8575
    @camillo8575 4 роки тому

    Hello excellent as always. How do you advice to instantiate "log" variable if I have more than one class in the same dart file?

    • @FilledStacks
      @FilledStacks  4 роки тому +1

      The same way. A log per class. Simply call getLogger in the class

  • @andrecytryn3745
    @andrecytryn3745 4 роки тому +6

    Great work as always! The package now is updated to 0.8.0 so its not possible to create the SimpleLogPrinter extended class as you did. But I adapted and gave you credit here in this github issue on the Logger repo. github.com/leisim/logger/issues/31
    So for those who are willing how to customize your loggers with colors and emojis like @FilledStacks did, just click the link and copy the example.
    Cheers and happy coding!

    • @alvin3171997
      @alvin3171997 4 роки тому

      Thank you for your help!

    • @FilledStacks
      @FilledStacks  4 роки тому

      Thanks for sharing! That's pretty cool, I'll check it out.

  • @pradeep422
    @pradeep422 5 років тому +1

    Hi, should I include logs in released version of my app or flutter just ignore those print and log statements while building release apk to reserve app size just code itself???

    • @FilledStacks
      @FilledStacks  5 років тому +1

      I do, especially when I've hooked up remote logging or logging to a file. If you're not doing that then you you can wrap your SimpleLogPrinter print code in an assert(() { /* log code here*/ }). Assert will only run in debug mode. Then you can add logger as a dev_dependency in your pubspec and not a full dependency.

    • @dharmendrapandey2668
      @dharmendrapandey2668 4 роки тому +1

      @@FilledStacks How do you log to file, im struggling ith this, can yo uplease send me some tutorials.

    • @FilledStacks
      @FilledStacks  4 роки тому +1

      @@dharmendrapandey2668 Hey, I don't have tutorials for that but I would add it in as a LogOutput which will use an queue to internally write out all the logs in order on a separate thread.

  • @charith2967
    @charith2967 2 роки тому

    Thanks for the video. How do we see these logs in production after deploying in Android or IOS platforms?

    • @FilledStacks
      @FilledStacks  2 роки тому

      You're welcome. We use Google cloud logging. You can add an addition log ouput that writes to cloud logging then you can look at the logs on there.

  • @user-gx3st2th8q
    @user-gx3st2th8q 4 роки тому

    With the logging package, are they saved between launches? If so, is it possible to adb retrieve the logs after a bit?

    • @FilledStacks
      @FilledStacks  4 роки тому

      No, nothing is saved. You'll have to add your own logging output and save to disk. Then you'll be able to retrieve it after a run

  • @kartikshrivastava1500
    @kartikshrivastava1500 2 роки тому

    Thanks for saving my time. I've a question, how can I get logs from a live app running on users device with firebase as backend.

    • @FilledStacks
      @FilledStacks  2 роки тому

      You should use Cloud Logging and wrap it in a service. Then you can create an additional LogOutput and when the log functio is called you send it to your Cloud Logging service.

    • @kartikshrivastava1500
      @kartikshrivastava1500 2 роки тому

      ​@@FilledStacks Great, thanks for quick info.

  • @abdula5842
    @abdula5842 3 роки тому

    if we use autogenerate route where do we put the code to track user activity since there is no genarate route function available

    • @FilledStacks
      @FilledStacks  3 роки тому

      You can add it as a navigation observer in the Material app. it passes you the route that it's going to so you can log it out.

  • @gregorysamaras7919
    @gregorysamaras7919 3 роки тому

    Is there any way those logs that you print to save em in a txt file ? Or any file type in the internal memory ?
    Thanks

    • @FilledStacks
      @FilledStacks  3 роки тому +1

      Yes, the logger package takes a LogOutput. You can build your own one which writes to a file. If you read the docs you'll see the options for it there.

    • @gregorysamaras7919
      @gregorysamaras7919 3 роки тому

      Thanks for the reply 💪 I will look into it

    • @FilledStacks
      @FilledStacks  3 роки тому

      @@gregorysamaras7919 :)

  • @carterv.31
    @carterv.31 5 років тому

    nice

  • @RaviPardeshi
    @RaviPardeshi 2 роки тому

    Can you please cover how to log this in a file and how to send it to server for reporting.

    • @FilledStacks
      @FilledStacks  2 роки тому

      Hey, yes. I'll write a tutorial on the cloud logging we use and also build a file output if needed for your other requirement. Don't know when, but it's been on my list of videos.

  • @Davidpeinao
    @Davidpeinao 5 років тому +8

    LOL there is a level called "wtf" 4:49

    • @FilledStacks
      @FilledStacks  5 років тому +1

      hahaha yeeaaah, you get those moments in code where that's helpful 😂

    • @naveenrgnrk18
      @naveenrgnrk18 4 роки тому

      That's actually 'What a terrible failure' level

  • @scalybur
    @scalybur 5 років тому

    Source of code dont exists

    • @FilledStacks
      @FilledStacks  5 років тому

      Yeah there's no source code for this. In the written you'll see it's just a few lines of code in one file so there's no need for having source code for it.

  • @jajasaria
    @jajasaria 5 років тому

    what did you eat to be good in oop?

    • @FilledStacks
      @FilledStacks  5 років тому +1

      🥝🥥🌶🍇🍩🍣 🍝

    • @jajasaria
      @jajasaria 5 років тому

      I need something like this sample in OOP. Can you provide a tutorial like this too? Real world sample

    • @FilledStacks
      @FilledStacks  5 років тому +1

      @@jajasaria This is tutorial is a real world example for Object oriented programming. Flutter is written in dart which is an Object oriented programming (OOP) language. All my tutorials are for real world examples. Logging depends on what you want to log. I'm just giving some general guidelines for logging. You can additional logs to what you know is important to your app.

    • @jajasaria
      @jajasaria 5 років тому

      @@FilledStacks yes i understand. what im saying is a tutorial more focus in OOP (Dart Programming) using realworld example like this one. The way you explain things is so amazing and i like it. thanks to this

    • @FilledStacks
      @FilledStacks  5 років тому

      @@jajasaria Thanks. I won't be covering anything around programming topics, I'd like to focus on concepts where you require programming knowledge. The reason I started making videos is because I couldn't find any practical guides to architecture or how to structure your code in general. No one talks about code separation, everyone is making videos for beginners so I'm sure you can find some very nice beginner OOP videos / courses out there. I'll stay focused on the real world side. Everything I've been showing is code principles that make OOP better, so in a sense these are all Object oriented programming tutorials.