Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flogs advanced logging framework

flog is an advanced logging framework develop in flutter that provides quick & simple logging solution. all logs are saved to the db which can then be exported as a zip file.

flogs is written in dart. it basically features two types of loggers (flog & datalog) with many of advanced features needed for logging. logs are saved in database which can then be exported in document directory of android|ios device. the logs are helpful when developer wants to analyze user activities within the app. these logs can be filtered and sorted easily. logs can easily be exported as zip file base on filter type, the zip file can then be uploaded to server or to use it locally.

many times we want to log set of data to analyze certain activity e.g. location (gps coordinates), device info, network requests etc. this helps us to quickly identify and fix the issue that is hard to debug when the app is in production. flogs provide such functionality to log data set into database. these logs can then be fetched by applying different convinience filters availale.

features

  1. logs events in files created separately every hour with ‘flogs’ logger. (24 hours)
  2. files can be compressed and exported for time and day filters
  3. clear logs easily
  4. save logs to custom path (supported in android only)
  5. export logs to custom path as zip file (supported in android only)
  6. custom log formatting
  7. csv support
  8. custom timestamps support
  9. custom data logging support with ‘datalogs’ logger.
  10. encryption support added
  11. multiple directory structures
  12. print logs as string
  13. export all or single types of logs
  14. advanced automation for deleting logs automatically
  15. exports html formatted exceptions
  16. log level support

use this package as a library

1. depend on it

add this to your package’s pubspec.yaml file:

dependencies:
  f_logs: ^1.0.x

2. install it

you can install packages from the command line:

with flutter

$ flutter packages get

alternatively, your editor might support flutter packages get. check the docs for your editor to learn more.

3. import it

now in your dart code, you can use:

import 'package:f_logs/f_logs.dart';

how to use framework

log files are exported on storage directory so it’s very important to add these permissions to your project’s manifest file first.

android

<uses-permission android:name="android.permission.write_external_storage"/>
<uses-permission android:name="android.permission.read_external_storage"/>

ios

<key>nsphotolibraryaddusagedescription</key>
<string>flogs would like to save photos from the app to your gallery</string>
<key>nsphotolibraryusagedescription</key>
<string>flogs would like to access your photo gallery for uploading images to the app</string>

to save logs, simply call any of the method mentioned below:

1. simple trace log

    flog.trace(
      classname: "homepage",
      methodname: "_buildrow1",
      text: "my log");

framework

2. simple debug log

    flog.debug(
      classname: "homepage",
      methodname: "_buildrow1",
      text: "my log");

3. simple info log

    flog.info(
      classname: "homepage",
      methodname: "_buildrow1",
      text: "my log");

4. simple warning log

    flog.warning(
      classname: "homepage",
      methodname: "_buildrow1",
      text: "my log";

5. simple error log

    flog.error(
      classname: "homepage",
      methodname: "_buildrow1",
      text: "my log");

6. simple severe log

    flog.severe(
      classname: "homepage",
      methodname: "_buildrow1",
      text: "my log");

7. severe log with exception and stacktrace

    flog.logthis(
      classname: "homepage",
      methodname: "_buildrow1",
      text: "my log",
      type: loglevel.severe, 
      exception: exception("this is an exception!"),
      stacktrace: stacktrace.current);

8. simple fatal log

    flog.fatal(
      classname: "homepage",
      methodname: "_buildrow1",
      text: "my log");

9. data type log

    flog.logthis(
      classname: "homepage",
      methodname: "_buildrow1",
      text: "my log",
      type: loglevel.severe,
      datalogtype: datalogtype.device.tostring());

available methods

flogs provide many convenience methods to save logs into or to fetch them from database, below is the list of all the methods available:

1. logthis

logs string data along with classname, methodname, logtext and the type of log (loglevel.severe, loglevel.info) etc. the same method can be used to log exception(s) or data logs. the difference between flog and datalogs is described above, you can also check out wiki for more details. if either classname or methodname is not provided, it will automatically be taken by getting calling class and method.

static logthis({
    string classname, // this is optional if not provided, then it will automatically be taken by getting calling class
    string methodname, // this is optional if not provided, then it will automatically be taken by getting calling method
    @required string text,
    @required loglevel type,
    exception exception,
    string datalogtype,
    stacktrace stacktrace,
}){}

2. trace

logs string data along with classname, methodname, logtext and the type of log (loglevel.severe, loglevel.info) etc. the same method can be used to log exception(s) or data logs. if either classname or methodname is not provided, it will automatically be taken by getting calling class and method.

static trace({
    string classname, // this is optional if not provided, then it will automatically be taken by getting calling class
    string methodname, // this is optional if not provided, then it will automatically be taken by getting calling method
    @required string text,
    exception exception,
    string datalogtype,
    stacktrace stacktrace,
}){}

3. debug

logs string data along with classname, methodname, logtext and the type of log (loglevel.severe, loglevel.info) etc. the same method can be used to log exception(s) or data logs. if either classname or methodname is not provided, it will automatically be taken by getting calling class and method.

static debug({
    string classname, // this is optional if not provided, then it will automatically be taken by getting calling class
    string methodname, // this is optional if not provided, then it will automatically be taken by getting calling method
    @required string text,
    exception exception,
    string datalogtype,
    stacktrace stacktrace,
}){}

4. info

logs string data along with classname, methodname, logtext and the type of log (loglevel.severe, loglevel.info) etc. the same method can be used to log exception(s) or data logs. if either classname or methodname is not provided, it will automatically be taken by getting calling class and method.

static info({
    string classname, // this is optional if not provided, then it will automatically be taken by getting calling class
    string methodname, // this is optional if not provided, then it will automatically be taken by getting calling method
    @required string text,
    exception exception,
    string datalogtype,
    stacktrace stacktrace,
}){}

framework

5. warning

logs string data along with classname, methodname, logtext and the type of log (loglevel.severe, loglevel.info) etc. the same method can be used to log exception(s) or data logs. if either classname or methodname is not provided, it will automatically be taken by getting calling class and method.

static warning({
    string classname, // this is optional if not provided, then it will automatically be taken by getting calling class
    string methodname, // this is optional if not provided, then it will automatically be taken by getting calling method
    @required string text,
    exception exception,
    string datalogtype,
    stacktrace stacktrace,
}){}

framework

6. error

logs string data along with classname, methodname, logtext and the type of log (loglevel.severe, loglevel.info) etc. the same method can be used to log exception(s) or data logs. if either classname or methodname is not provided, it will automatically be taken by getting calling class and method.

static error({
    string classname, // this is optional if not provided, then it will automatically be taken by getting calling class
    string methodname, // this is optional if not provided, then it will automatically be taken by getting calling method
    @required string text,
    exception exception,
    string datalogtype,
    stacktrace stacktrace,
}){}

framework

7. severe

logs string data along with classname, methodname, logtext and the type of log (loglevel.severe, loglevel.info) etc. the same method can be used to log exception(s) or data logs. if either classname or methodname is not provided, it will automatically be taken by getting calling class and method.

static severe({
    string classname, // this is optional if not provided, then it will automatically be taken by getting calling class
    string methodname, // this is optional if not provided, then it will automatically be taken by getting calling method
    @required string text,
    exception exception,
    string datalogtype,
    stacktrace stacktrace,
}){}

framework

8. fatal

logs string data along with classname, methodname, logtext and the type of log (loglevel.severe, loglevel.info) etc. the same method can be used to log exception(s) or data logs. if either classname or methodname is not provided, it will automatically be taken by getting calling class and method.

static fatal({
    string classname, // this is optional if not provided, then it will automatically be taken by getting calling class
    string methodname, // this is optional if not provided, then it will automatically be taken by getting calling method
    @required string text,
    exception exception,
    string datalogtype,
    stacktrace stacktrace,
}){}

framework

9. printlogs

fetches all the logs from database and prints them as a string using stringbuffer()

static printlogs() async {}

framework

10. getalllogsbycustomfilter

accepts list of filters as an arguments and returns list of logs based on the provided filters. the use of filters with their usage is explained in wiki, please checkout wiki for more details.

list<filter> filters = [filter.greaterthan('[fieldname]', '[value]')]

static future<list<log>> getalllogsbycustomfilter(
    {list<filter> filters}) async {}

framework

11. getalllogsbyfilter

a convenience method that filters data based on the provided filter params e.g. datalogstype (datalogtype.device, datalogtype.network), loglevels(loglevel.severe, loglevel.info), starttimeinmillis (millisec of the day you from where you want logs to be fetched), endtimeinmillis (milisec of the day you till you want logs to be fetched) and filtertype (filtertype.last_hour, filtertype.last_24_hours, filtertype.today, filtertype.week, filtertype.all). filter type can’t be used with starttimeinmillis, endtimeinmillis, if so the priority will be given to starttimeinmillis, endtimeinmillis. in-order to have full control over filters, use method provided above.

static future<list<log>> getalllogsbyfilter(
    {list<string> datalogstype,
    list<string> loglevels,
    int starttimeinmillis,
    int endtimeinmillis,
    filtertype filtertype}}) async {}

framework

12. getalllogs

fetches all the logs from database and returns a list of logs.

static future<list<log>> getalllogs() async {}

framework

13. exportlogs

exports logs to external storage under flog directory.

static exportlogs() async {}

framework

14. clearlogs

clears all the logs stored in database.

static clearlogs() {}

framework

framework

15. applyconfigurations

apply user provided configurations to flogs.

static applyconfigurations(logsconfig config) {}

framework

16. deletealllogsbyfilter

accepts list of filters as an arguments and delete logs based on the provided filters. the use of filters with their usage is explained in wiki, please checkout wiki for more details.

list<filter> filters = [filter.greaterthan('[fieldname]', '[value]')]

static deletealllogsbyfilter(
    {list<filter> filters}) async {}

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.