All Projects → Jerey-Jobs → Klog

Jerey-Jobs / Klog

Licence: other
🎼 A Kotlin log lib, making the output log more elegant and more beautiful.

Programming Languages

kotlin
9241 projects
java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to Klog

k3log
三大王日志,一款开箱即用且高效,快捷,安全的golang日志,基于uber zap
Stars: ✭ 32 (+52.38%)
Mutual labels:  log
LogESP
Open Source SIEM (Security Information and Event Management system).
Stars: ✭ 162 (+671.43%)
Mutual labels:  log
base
小而美的业务基础框架,也是本项目的核心
Stars: ✭ 47 (+123.81%)
Mutual labels:  log
woodpecker-client
异常日志收集客户端 环境隔离版本
Stars: ✭ 51 (+142.86%)
Mutual labels:  log
LogDNA-Android-Client
Android client for LogDNA
Stars: ✭ 22 (+4.76%)
Mutual labels:  log
LogiAM
基于日志模板构建,采集任务动态管控、数据质量精确度量,一站式日志采集平台
Stars: ✭ 199 (+847.62%)
Mutual labels:  log
datalogger
DataLogger foi projetado para ser uma biblioteca simples de log com suporte a vários providers.
Stars: ✭ 46 (+119.05%)
Mutual labels:  log
RFKit
Toolkit for daily Cocoa development. Since 2012.
Stars: ✭ 20 (-4.76%)
Mutual labels:  log
JJSwiftLog
Swift log library for all platform
Stars: ✭ 51 (+142.86%)
Mutual labels:  log
TLog
Android日志工具
Stars: ✭ 16 (-23.81%)
Mutual labels:  log
aiologger
Asynchronous logging for Python and asyncio
Stars: ✭ 92 (+338.1%)
Mutual labels:  log
pyqso
PyQSO is a contact logging tool for amateur radio operators.
Stars: ✭ 75 (+257.14%)
Mutual labels:  log
rust cms
使用Rust编写一个CMS(内容管理系统)可以做为个人博客,公司网站
Stars: ✭ 32 (+52.38%)
Mutual labels:  log
ng-logger
Angular logger service
Stars: ✭ 65 (+209.52%)
Mutual labels:  log
PCPXlog
通过简单配置将日志同时输出到console、file、MongoDB | 可以pip安装
Stars: ✭ 13 (-38.1%)
Mutual labels:  log
log
Aplus Framework Log Library
Stars: ✭ 14 (-33.33%)
Mutual labels:  log
Log
Daily logging tool and data visualizer.
Stars: ✭ 30 (+42.86%)
Mutual labels:  log
fakessh
A dockerized fake SSH server honeypot written in Go that logs login attempts.
Stars: ✭ 42 (+100%)
Mutual labels:  log
loggie
A lightweight, cloud-native data transfer agent and aggregator
Stars: ✭ 844 (+3919.05%)
Mutual labels:  log
crab
Golang API Framework
Stars: ✭ 57 (+171.43%)
Mutual labels:  log

Klog - A Kotlin Log lib

简介 (what is Klog?)

Klog是用Kotlin所写的,利用其类扩展,实现了链式调用时,在不破坏其代码整体性的情况下,能够实现数据打印跟踪的log库.

  • 优点:
    1.链式打印
    2.自动识别调用方类名为TAG
    3.打印线程号,代码行 (默认不开启,需要开启请 Klog.getSettings().setBorderEnable(true))
  • 缺点:
    由于Kotlin对于伴生类方法的惰性加载优化, 在kt中调用可以使用 Klog.d("hello"),但是在java中,其使用的是内部类的方式实现惰性加载.
    因此在java中, 调用方式变为了 Klog.Companion.i("test");

有更好的实现方式的欢迎pr or issues

Download

project's build.gradle

  	allprojects {
  		repositories {
              ...
              maven { url 'https://jitpack.io' }
  		}
  	}

module's build.gradle (模块的build.gradle)

	dependencies {
	        compile 'com.github.Jerey-Jobs:Klog:v0.2'
	}

或者, 您可以直接将Klog.kt文件拷贝至您的项目(推荐)

说明(Explanation)

无论什么语言, 程序员都需要输出log, Kotlin的语法扩展功能可为我们带来更新奇的输出log模式.

输出log的目的,无非两种情况
1.用来表明程序执行到哪了
2.打印数据处理前后的值

那么Klog带来了数据边处理边打印的模式.

比如这种边处理字符串边打印的模式.

    str.log()                   //直接输出该对象toString
       .toUpperCase()
       .log("upper")             //输出带提示的处理结果
       .toLowerCase()            //继续处理
       .log("lower")

又比如在lambda时,我们调试时需要跟踪数据被处理的情况

    var list = arrayListOf<String>("aaa", "bb", "cccc", "ddddd")
    list.log("init")
        .map { it -> it.toUpperCase() }
        .log("after map")
        .filter { it -> it.length > 2 }
        .log("after filter")

又或者,我们需要直接打印

    //修改Klog设置, 开启边框打印
    Klog.getSettings()
            .setBorderEnable(true)

    Klog.a("aaaaaaa")            //普通log输出方式1
    Klog.a(contents = "bbbbb")   //普通log输出方式2
    Klog.i("jerey", "aaaaaaa")    //带tag输出

so, Kotlin的类扩展为我们带来无限遐想

License

Copyright 2017 Jerey-Jobs.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].