ddlog-printing information in different colors

Source: Internet
Author: User

1. Installing plugins

Xcodecolors

Github Link: https://github.com/robbiehanson/XcodeColors

Open the Xcodecolors project and compile. It will install Plug and xcodecolors.xcplugin in your computer. Specific path in: ~/library/application Support/developer/shared/xcode/plug-ins/xcodecolors.xcplugin (can take a look).

2. Introduction of third-party libraries

Cocoalumberjack

Github Link: https://github.com/CocoaLumberjack/CocoaLumberjack

3. Modify your printing information to change the NSLog to Ddlog printing, the best new project to use

(ii) Some introductions of Ddlog

Ddlog: Basic class, which must be introduced.

Ddasllogger: Supports writing debug statements to Apple's logs. It is generally being developed for Mac. Optional.

Ddttylogger: Supports writing debug statements to the Xcode console. Even if we want to use it. Optional.

Ddfilelogger: Supports writing debug statements to the file system. Optional.

Ddlog the output level by default provides several of the following:

Ddlogerror: Defining output error text

Ddlogwarn: Define output warning text

Ddloginfo: Defining output Message Text

Ddlogdebug: Defining Output Debug Text

Ddlogverbose: Defining output verbose text

The log levels provided are:

Log_level_error: Only error logs are displayed.

Log_level_warn: including: Log_level_error

Log_level_info: including: Log_level_warn

Log_level_debug: including: Log_level_info

Log_level_verbose: including: Log_level_debug

Log_level_off: Close Log

(iii) partial use of Ddlog

#import "CocoaLumberjack.h"

    static const int Ddloglevel = ddloglevelverbose;//defines the log level    [Ddlog Addlogger:[ddttylogger sharedinstance]];// Initialize the Ddlog log output, where we only want the Xcode console output    [[Ddttylogger sharedinstance] setcolorsenabled:yes];//enable color discrimination    Ddlogerror (@ "error message"); Red    Ddlogwarn (@ "Warning%@", @ "ASD"),//Orange    Ddloginfo (@ "prompt message:%@", @ "quack");//default is black    ddlogverbose (@ "Details error:% D ", 1016); Default is Black

Printing effect:

Tips: If the print color does not change

    • Open Product--Edit Scheme
    • Select Run-> "Arguments" tab
    • Add a new environment Variable named "Xcodecolors" with a value of Yes
    • OK, now is the time to witness the miracle, run it once, and you can see.

ddlog-printing information in different colors

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.