Changeset 101 in libcf for trunk/src/cf_log.c
- Timestamp:
- 05/28/13 23:45:43 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cf_log.c
r100 r101 49 49 if (gLogArray.ctxPool[__mapid] == NULL) \ 50 50 return CF_ERROR_LOG_NOT_MAPPED_ID 51 52 #define GET_LOG_LEVEL() \ 53 ((gLogArray.level == CF_LOG_NO_LEVEL) \ 54 ? gLogArray.ctxSize \ 55 : gLogArray.level) 56 57 #define CHECK_LOG_LEVEL(__mapid) \ 58 if (GET_LOG_LEVEL () < mapid) \ 59 return CF_OK 51 60 52 61 #define LOCK_LOG_CTX(__ctx) CF_Mutex_Lock (&__ctx->mutex) … … 519 528 * @return 성공 시, CF_OK; 실패 시, 오류 코드 520 529 * 521 * @param logPool 아이디 넘버 최대 값 530 * @param poolSize 로그 풀 크기로, 로그 아이디 넘버의 최대 값 531 * @param level 로그 레벨 532 * 533 * @see CF_LOG_NO_LEVEL 522 534 */ 523 535 int 524 CF_Log_Initialize (const int logPool)536 CF_Log_Initialize (const int poolSize, const int level) 525 537 { 526 538 memset (&gLogArray, 0x00, sizeof (CF_LOG_ARRAY)); 527 539 528 if ( logPool> 0)540 if (poolSize > 0) 529 541 { 530 542 gLogArray.ctxPool = 531 (CF_Log_Ctx *) calloc ((size_t) logPool, sizeof (CF_Log_Ctx));543 (CF_Log_Ctx *) calloc ((size_t) poolSize, sizeof (CF_Log_Ctx)); 532 544 if (gLogArray.ctxPool == NULL) 533 545 return CF_ERROR_LOG_INITIALIZE; 534 gLogArray.ctxSize = logPool;535 gLogArray.level = CF_LOG_NO_LEVEL;546 gLogArray.ctxSize = poolSize; 547 gLogArray.level = level; 536 548 } 537 549 … … 581 593 CF_Log_Ctx ctx = NULL; 582 594 595 CHECK_LOG_LEVEL (mapid); 596 583 597 result = CF_Log_CreateCtx (path, memsize, &ctx); 584 598 if (result < 0) … … 602 616 CF_Log_Close (const int mapid) 603 617 { 618 CHECK_LOG_LEVEL (mapid); 619 604 620 return CF_Log_UnmapCtxID (mapid); 605 621 } … … 652 668 653 669 return result; 654 }655 656 /**657 * 현재 설정된 로그 레벨을 가져옴658 *659 * @return 로그 레벨이 설정된 경우, 로그 풀 크기; 그 외에, 설정된 로그 레벨660 */661 static int662 CF_Log_GetLevel (void)663 {664 return (gLogArray.level == CF_LOG_NO_LEVEL) ? gLogArray.ctxSize665 : gLogArray.level;666 }667 668 /**669 * 로그 레벨을 설정670 * 지정된 로그 레벨 이하의 아이디 넘버만 로그로 기록하도록 설정671 *672 * @return 성공 시, CF_OK; 실패 시, 오류 코드673 *674 * @param level 설정할 로그 레벨675 *676 * @see CF_LOG_NO_LEVEL677 */678 int679 CF_Log_SetLevel (const int level)680 {681 gLogArray.level = level;682 683 return CF_OK;684 670 } 685 671 … … 703 689 va_list valist; 704 690 705 result = CF_Log_GetLevel (); 706 if (result < mapid) 707 return CF_OK; 691 CHECK_LOG_LEVEL (mapid); 708 692 709 693 result = CF_Log_GetMappedCtx (mapid, &ctx);
Note:
See TracChangeset
for help on using the changeset viewer.