Coder Social home page Coder Social logo

mikigo / funnylog Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 0.0 1.62 MB

此仓库已经迁移到公司github仓库:https://github.com/linuxdeepin/funnylog

Home Page: https://github.com/linuxdeepin/funnylog

License: Apache License 2.0

Python 98.53% Shell 1.47%
logging python

funnylog's Introduction

FunnyLog

一个简单易用、功能强大的日志工具。

只需要加一个装饰器,就能自动日志输出类里面所有的方法的功能说明。


Documentation: https://funny-dream.github.io/funnylog

Source Code: https://github.com/funny-dream/funnylog


安装

pip install funnylog

使用说明

from funnylog import logger
from funnylog import log
from funnylog.conf import setting

setting.CLASS_NAME_ENDSWITH = ("Log",)
logger("DEBUG")


class BaseLog:

    def base_self_method(self):
        """我是 基类 里面的实例方法"""

    @classmethod
    def base_cls_method(self):
        """我是 基类 里面的类方法"""

    @staticmethod
    def base_static_method():
        """我是 基类 里面的静态方法"""

# 注意这里,只需要在这里挂一个装饰器
@log
class TestLog(BaseLog):
    """继承了基类BaseLog"""

    def self_method(self):
        """我是 类 里面的实例方法"""

    @classmethod
    def cls_method(self):
        """我是 类 里面的类方法"""

    @staticmethod
    def static_method():
        """我是 类 里面的静态方法"""


if __name__ == '__main__':
    # @log装饰器自动打印
    TestLog().self_method()
    TestLog().cls_method()
    TestLog().static_method()
    # 直接调用基类里面的方法,也能自动打印
    TestLog().base_self_method()
    TestLog().base_cls_method()
    TestLog().base_static_method()

终端输出效果:


funnylog's People

Contributors

mikigo avatar

Stargazers

 avatar

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.