Index: /trunk/include/cf_log.h
===================================================================
--- /trunk/include/cf_log.h	(revision 18)
+++ /trunk/include/cf_log.h	(revision 19)
@@ -14,7 +14,19 @@
 #define CF_ERROR_LOG_UNLOCK_CTX			CF_ERROR_LOG - 6
 #define CF_ERROR_LOG_FLUSH				CF_ERROR_LOG - 7
+#define CF_ERROR_LOG_INVALID_MAPID		CF_ERROR_LOG - 8
+#define CF_ERROR_LOG_NOT_MAPPED_ID		CF_ERROR_LOG - 9
+#define CF_ERROR_LOG_ALREADY_MAPPED_ID	CF_ERROR_LOG - 10
+#define CF_ERROR_LOG_NOT_INITIALIZE		CF_ERROR_LOG - 11
 
 #define CF_LOG_BUFFER_DEFAULT			-1
 #define CF_LOG_BUFFER_NO				0
+
+#define CF_LOG_OPEN(__id,__file,__memsize)				\
+	CF_Log_MapCtxID (__id, CF_Log_CreateCtx (__file, __memsize))
+
+#define CF_LOG_WRITE(__id,__pf,__fmt,...)				\
+	CF_Log_Write (CF_Log_GetMappedCtx (__id),__pf,__fmt,##__VA_ARGS__)
+
+#define CF_LOG_CLOSE	CF_Log_UnmapCtxID
 
 typedef void *	CF_Log_Ctx;
@@ -35,11 +47,11 @@
 
 CF_EXPORT int
+CF_Log_DestroyCtx		(CF_Log_Ctx ctx);
+
+CF_EXPORT int
 CF_Log_SetMultiThread	(CF_Log_Ctx ctx);
 
 CF_EXPORT int
 CF_Log_UnsetMultiThread	(CF_Log_Ctx ctx);
-
-CF_EXPORT int
-CF_Log_DestroyCtx		(CF_Log_Ctx ctx);
 
 CF_EXPORT int
@@ -51,4 +63,14 @@
 CF_Log_Flush			(CF_Log_Ctx ctx);
 
+CF_EXPORT int
+CF_Log_MapCtxID			(const int			mapid,
+						 const CF_Log_Ctx	ctx);
+
+CF_EXPORT int
+CF_Log_UnmapCtxID		(const int mapid);
+
+CF_EXPORT CF_Log_Ctx
+CF_Log_GetMappedCtx		(const int mapid);
+
 #ifdef __cplusplus
 }
Index: /trunk/src/cf_log.c
===================================================================
--- /trunk/src/cf_log.c	(revision 18)
+++ /trunk/src/cf_log.c	(revision 19)
@@ -201,4 +201,14 @@
 CF_Log_Finalize (void)
 {
+	int mapid = 0;
+
+	for (mapid = 0 ; mapid < gLogEnvironment.ctxSize ; mapid++)
+	{
+		CF_Log_UnmapCtxID (mapid);
+	}
+
+	if (gLogEnvironment.ctxPool != NULL)
+		free (gLogEnvironment.ctxPool);
+
 	memset (&gLogEnvironment, 0x00, sizeof (CF_LOG_ENVIRONMENT));
 
@@ -257,30 +267,4 @@
 
 int
-CF_Log_SetMultiThread (CF_Log_Ctx ctx)
-{
-	CF_LOG_CTX * context = (CF_LOG_CTX *) ctx;
-
-	CHECK_INVALID_CTX (ctx);
-
-	if (CF_Mutex_Create (&context->mutex) < 0)
-		return CF_ERROR_LOG_SET_MULTITHREAD;
-
-	return CF_OK;
-}
-
-int
-CF_Log_UnsetMultiThread (CF_Log_Ctx ctx)
-{
-	CF_LOG_CTX * context = (CF_LOG_CTX *) ctx;
-
-	CHECK_INVALID_CTX (ctx);
-
-	if (CF_Mutex_Destory (&context->mutex) < 0)
-		return CF_ERROR_LOG_UNSET_MULTITHREAD;
-
-	return CF_OK;
-}
-
-int
 CF_Log_DestroyCtx (CF_Log_Ctx ctx)
 {
@@ -313,4 +297,30 @@
 
 int
+CF_Log_SetMultiThread (CF_Log_Ctx ctx)
+{
+	CF_LOG_CTX * context = (CF_LOG_CTX *) ctx;
+
+	CHECK_INVALID_CTX (ctx);
+
+	if (CF_Mutex_Create (&context->mutex) < 0)
+		return CF_ERROR_LOG_SET_MULTITHREAD;
+
+	return CF_OK;
+}
+
+int
+CF_Log_UnsetMultiThread (CF_Log_Ctx ctx)
+{
+	CF_LOG_CTX * context = (CF_LOG_CTX *) ctx;
+
+	CHECK_INVALID_CTX (ctx);
+
+	if (CF_Mutex_Destory (&context->mutex) < 0)
+		return CF_ERROR_LOG_UNSET_MULTITHREAD;
+
+	return CF_OK;
+}
+
+int
 CF_Log_Write (CF_Log_Ctx	ctx,
 			  const char	* prefix,
@@ -373,2 +383,43 @@
 	return CF_OK;
 }
+
+int
+CF_Log_MapCtxID (const int			mapid,
+				 const CF_Log_Ctx	ctx)
+{
+	if (gLogEnvironment.ctxPool == NULL || gLogEnvironment.ctxSize <= 0)
+		return CF_ERROR_LOG_NOT_INITIALIZE;
+
+	if (gLogEnvironment.ctxPool[mapid] != NULL)
+		return CF_ERROR_LOG_ALREADY_MAPPED_ID;
+
+	gLogEnvironment.ctxPool[mapid] = ctx;
+
+	return CF_OK;
+}
+
+int
+CF_Log_UnmapCtxID (const int mapid)
+{
+	if (gLogEnvironment.ctxPool == NULL || gLogEnvironment.ctxSize <= 0)
+		return CF_ERROR_LOG_NOT_INITIALIZE;
+
+	if (gLogEnvironment.ctxPool[mapid] == NULL)
+		return CF_ERROR_LOG_NOT_MAPPED_ID;
+
+	CF_Log_DestroyCtx (gLogEnvironment.ctxPool[mapid]);
+
+	free (gLogEnvironment.ctxPool[mapid]);
+	gLogEnvironment.ctxPool[mapid] = NULL;
+
+	return CF_OK;
+}
+
+CF_Log_Ctx
+CF_Log_GetMappedCtx (const int mapid)
+{
+	if (gLogEnvironment.ctxPool == NULL || gLogEnvironment.ctxSize <= 0)
+		return NULL;
+
+	return gLogEnvironment.ctxPool[mapid];
+}
Index: /trunk/test/makefile
===================================================================
--- /trunk/test/makefile	(revision 18)
+++ /trunk/test/makefile	(revision 19)
@@ -91,5 +91,5 @@
 
 clean: dummy
-	rm -rf log.txt
+	rm -rf *.txt
 	rm -rf $(TARGET_PATH) $(OBJ_PATH)
 
Index: /trunk/test/test.c
===================================================================
--- /trunk/test/test.c	(revision 18)
+++ /trunk/test/test.c	(revision 19)
@@ -13,20 +13,22 @@
 CF_Debug_CallStack	gDebugCallstack;
 
-CF_Log_Ctx			gLogCtx;
-
 const char * file = "./log.txt";
 
 void log_test (const char * message)
 {
-	int i = 0;
+	int			i, j;
+	char		idname[16] = {0x00,};
+	CF_Log_Ctx	gLogCtx;
 
 	CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
 
+	CF_Log_Initialize (10);
+
 	gLogCtx = CF_Log_CreateCtx (file, CF_LOG_BUFFER_DEFAULT);
-	if (gDebugCtx == NULL)
-		CF_DEBUG_PRINT (stderr, "create debug ctx error\n");
+	if (gLogCtx == NULL)
+		CF_DEBUG_PRINT (stderr, "create log ctx error\n");
 
 	for (i = 0 ; i < 10000 ; i++)
-		CF_Log_Write (gLogCtx, "TEST", "turn %d\n", i);
+		CF_Log_Write (gLogCtx, "LOG_TEST", "turn %d\n", i);
 
 	CF_DEBUG_CALLSTACK_POP (gDebugCtx, &gDebugCallstack);
@@ -39,4 +41,22 @@
 
 	CF_Log_DestroyCtx (gLogCtx);
+
+	///////////////////
+
+	for (i = 0 ; i < 10 ; i++)
+	{
+		sprintf (idname, "logid%d.txt", i);
+		CF_LOG_OPEN (i, idname, CF_LOG_BUFFER_NO);
+	}
+
+	for (i = 0 ; i < 10 ; i++)
+	{
+		for (j = 0 ; j < 10000 ; j++)
+			CF_LOG_WRITE (i, "LOG_ID_TEST", "turn %d\n", j);
+
+		CF_LOG_CLOSE (i);
+	}
+
+	CF_Log_Finalize ();
 }
 
@@ -100,7 +120,4 @@
 	gDebugCtx = CF_Debug_CreateCtx ();
 
-	if (gLogCtx == NULL)
-		CF_DEBUG_PRINT (stderr, "create log ctx error\n");
-
 	CF_DEBUG_CALLSTACK_PUSH (gDebugCtx);
 
