Giter Club home page Giter Club logo

aoplogger's Introduction

#AOPLogger

##简介

基于iOS开源工具Aspects实现的面向切面日志组件

##方法介绍

  1. (void)logWithDict:(NSDictionary *)dict; 通过NSDictionary对象向项目中注入Log信息

  2. (void)removeAOPLoggers; 移除所有通过AOPLogger注入的log信息

##快速上手

#import "AOPLogger.h"
........
NSDictionary *config = @{
    @"ViewController": @{
         AOPLoggerSelectors: @[
               @{
                   AOPLoggerSelectorName: @"btnClick:",
                   AOPLoggerPosition: AOPPositionAfter,
                   AOPLoggerHandlerBlock:^(id<AspectInfo> aspectInfo){
                          NSLog(@"AOP: button pressed in %@", aspectInfo.instance);
                    }
               },
               @{
                   AOPLoggerSelectorName: @"repeat:",
                   AOPLoggerPosition: AOPPositionBefore,
                   AOPLoggerHandlerBlock:^(id<AspectInfo> aspectInfo, NSString *str){
                            NSLog(@"AOP: repeat str %@", str);
                     }
                  }
             ]
        }
 };
    
 [AOPLogger logWithDict:config]; 

##DEMO

详见AOPLoggerDemo

##FAQ

Q1: 如何引入AOPLogger?

A1: 只需将AOPLogger.h、AOPLogger.m、Aspects.h、Aspects.m这4个文件引入您的项目中即可。

Q2: 为何要使用AOPLogger?

A2:面向切面编程(AOP)是一种非常好的编程理念,将日志逻辑与业务逻辑解耦,是AOP的经典应用。通过AOPLogger,您可以把日志代码以字典形式动态添加到实际需要添加日志信息的类中。AOPLogger利用了Objective-C的Method-Swizzling,动态添加了日志信息。

Q3: AOPLogger和其他Log组件有什么不同?

A3: AOPLogger仅提供了一种日志注入的方式,可以结合其他Log组件(例如DDLog)使用,效果更佳。

##其他说明

本项目基于开源工具Aspects(https://github.com/steipete/Aspects),参考了okcomp/AspectsDemo

aoplogger's People

Contributors

epsilonx avatar

Watchers

 avatar  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.