Giter Site home page Giter Site logo

easylog's Introduction

EasyLog

An easy way to customize your log in Android.

Background

There are various requirements for client logging.

Classification by log output destinations:

  • Output to console
  • Output to file
  • Output to database
  • Output to server

Classification by log content processing:

  • Formatting logs
  • Encrypting logs
  • Compressing logs
  • Appending information

Classification by development usability:

  • Automatic tag generation
  • One-time tags
  • Support for format arguments
  • Printing lists and maps

Different business scenarios may select and combine some of these logging options in any order, and may also add new logging processing logic.

Easylog allows you to freely combine your logging processing logic in any order.

Let's say, you have the following log processing process:

pic

The origin log is divied into two process flow.

Or, another log processing process:

pic2

The origin log are classified and each has it own processing logic.

The log processing logic is like a Flexible production line. By EasyLog, it is easy to customize your own Flexible production line.

EasyLog is designed with chain of responsibility, each log processing logic is abstracted as anInterceptor<T>. The Interceptors are not standalone, they are chained with each other. It means the output of previous Interceptor is the input of the next one.

1. Initialization

EasyLog.addInterceptor(LogcatInterceptor()) // add logcat intercepter
EasyLog.addInterceptor(SinkInterceptor()) // add file interceptor which keeps log in file

2. Use it everywhere

log string

EasyLog.log("abcd")

log POJO

EasyLog.log(User(name = "taylor", age = 20))

log List

val array = listOf(1,2,3)
EasyLog.list(array)// output ”[1, 2, 3]“

val users = listOf(
    User(name = "peter", age = 18),
    User(name = "joice", age = 20),
    User(name = "martin", age = 10),
)
EasyLog.list(users) { it.name } // output ”[peter, joice, martin]“

log Map

val map = mapOf(
    "a" to mapOf( "1" to true), 
    "b" to mapOf( "2" to false, "3" to true)
)
EasyLog.map(map)

output:

   {
        [a] = { [1] = true },
        [b] =  {
            [2] = false,
            [3] = true
        }
    }

auto-generated/one-time tag

Tag is auto-generated by default.

class UserManger {
  fun print() {
    EasyLog.log("taylor")
  }
}

The auto-generated tag is "UserManager"

One-time tag is supported:

EasyLog.tag("test").log("abcd")

log level supported

EasyLog.log("taylor", DEBUG)

Log level is supported by parameter not function

format arguments supported

EasyLog.log("end %s", DEBUG, "ab")

one-time interceptor

EasyLog.interceptor(FrameInterceptor()).log("higlight")
EasyLog.log("after highlight")

output:

┌──────────────────────────────────────────────────────────────────────────
│highlight                    
└──────────────────────────────────────────────────────────────────────────
after highlight

easylog's People

Contributors

wisdomtl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

easylog's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.