Changeset 101 in libcf
- Timestamp:
- 05/28/13 23:45:43 (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/cf_log.h
r98 r101 31 31 * 로그 레벨 사용 안함 32 32 * 33 * @see CF_Log_ SetLevel33 * @see CF_Log_Initialize 34 34 */ 35 35 #define CF_LOG_NO_LEVEL -1 … … 40 40 41 41 CF_EXPORT int 42 CF_Log_Initialize (const int logPool); 42 CF_Log_Initialize (const int poolSize, 43 const int level); 43 44 44 45 CF_EXPORT int … … 65 66 const CF_BOOL flag); 66 67 67 CF_EXPORT int68 CF_Log_SetLevel (const int level);69 70 68 #ifdef __cplusplus 71 69 } -
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); -
trunk/test/log.c
r98 r101 13 13 char logname[16] = {0x00,}; 14 14 15 if (CF_Log_Initialize (10 ) < 0)15 if (CF_Log_Initialize (10, 5) < 0) 16 16 { 17 17 fprintf (stderr, "failed to init. log\n"); … … 25 25 fprintf (stderr, "failed to open log\n"); 26 26 } 27 28 if (CF_Log_SetLevel (5) < 0)29 fprintf (stderr, "failed to set log level\n");30 27 31 28 for (i = 0 ; i < 10 ; i++) -
trunk/test/test.c
r98 r101 106 106 107 107 /* initialize */ 108 if (CF_Log_Initialize (10 ) < 0)108 if (CF_Log_Initialize (10, 5) < 0) 109 109 { 110 110 fprintf (stderr, "failed to init. log\n"); … … 118 118 fprintf (stderr, "failed to open log\n"); 119 119 } 120 121 if (CF_Log_SetLevel (5) < 0)122 fprintf (stderr, "failed to set log level\n");123 120 124 121 for (i = 0 ; i < 10 ; i++)
Note:
See TracChangeset
for help on using the changeset viewer.