ACE (1): use ACE Log facility

Source: Internet
Author: User

1. Preface:

The main macros for using ace log facilities are as follows:

Ace_debug (commonly used): used for debugging statements

Ace_error (commonly used): used for warning and error

Ace_trace: used for tracking information

2. Create a console project log_text (vs2008)

4. Modify the log_text.cpp File

// Log_text.cpp: defines the entry point of the console application. <Br/> // </P> <p> # include "stdafx. H "</P> <p> # define ace_ntrace 0 // whether macro ace_trace 0 is enabled, 1 is disabled, disabled by default <br/> # include "ACE/log_msg.h" </P> <p> void Foo (void); </P> <p> int ace_tmain (INT, ace_tchar * []) <br/>{< br/> ace_trace (ace_text ("Main"); <br/> ace_debug (lm_info, ace_text ("% t Hi Mom! /N "); <br/> Foo (); <br/> ace_debug (lm_info, ace_text (" % I Howdy Pardner/N "))); <br/> system ("pause"); <br/> return 0; <br/>}</P> <p> void Foo (void) <br/>{< br/> ace_trace (ace_text ("foo"); <br/> ace_debug (lm_info, ace_text ("% I Howdy Pardner/N"); <br/>}

Running result:

5. If you want to run in vs2008, you must modify the project properties:

Right-click Project-> Properties

(1) C/C ++ attributes

General -- add the include directory: $ (ace_root)

Code Generation: multi-thread debugging DLL (MDD)

(2) linker

General -- Additional library Directory: $ (ace_root)/lib

Input -- add dependency: aced. Lib

Advanced -- random base address: Disable image randomization

Advanced -- Data Execution Protection: Default Value

6. computer environment variables

Add ace_root and set its value to: D:/ace_5.6/ace_wrappers.

Add D:/ace_5.6/ace_wrappers/bin and D:/ace_5.6 to the path variable.

7. compile the project

8. Execute log_text.exe in the console and output:

If # define ace_ntrace 0 is not added to the project, the running result is:
Hi mom
Howdy Pardner
Goodnight

Ace_trace does not work. Check the book and find that this function is disabled by default. solution:

You can use either of the following methods to solve the problem:
(1) modify the file code
# Define ace_ntrace 0
# Include "ACE/log_msg.h"

Note that # define ace_ntrace 0 must be in # include "ACE/log_msg.h"; otherwise, ace_trace will not work.

(2) Add the definition macro command on the Compilation command.
You can add the following option-dace_ntrace

Summary:

1. # include "ACE/log_msg.h" contains many macros, including a large number of debugging macros such as ace_debug, which makes programming easier.

2. ace_log _ MSG: Process --- obtain or set the mask of the Process range, which affects the log severity of the ace_log_msg instance. ace_log_msg: thread -- specifies the thread proprietary mask, this second parameter is very important if you want to set an individual severity mask on the ace_log_msg instance.

Reference: http://blog.csdn.net/sws9999/archive/2010/10/14/5940423.aspx

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.