2 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 * (C) Copyright IBM Corp. 1997,2002
7 * Redistribution and use in source and binary forms are permitted
8 * provided that this notice is preserved and that due credit is
9 * given to IBM Corporation. This software is provided ``as is''
10 * without express or implied warranty.
14 #include <slapi_common.h>
23 #include <ldap_config.h>
27 #include <ldap_pvt_thread.h>
29 /* Single threads access to routine */
30 ldap_pvt_thread_mutex_t slapi_printmessage_mutex;
31 char *slapi_log_file = NULL;
32 int slapi_log_level = SLAPI_LOG_PLUGIN;
48 assert( subsystem != NULL );
49 assert( fmt != NULL );
51 ldap_pvt_thread_mutex_lock( &slapi_printmessage_mutex ) ;
53 /* for now, we log all severities */
54 if ( level <= slapi_log_level ) {
55 fp = fopen( slapi_log_file, "a" );
64 while ( lockf( fileno( fp ), F_LOCK, 0 ) != 0 ) {
69 ltm = localtime( ¤tTime );
70 strftime( timeStr, sizeof(timeStr), "%x %X", ltm );
73 fprintf( fp, " %s: ", subsystem );
74 vfprintf( fp, fmt, arglist );
75 if ( fmt[ strlen( fmt ) - 1 ] != '\n' ) {
80 lockf( fileno( fp ), F_ULOCK, 0 );
89 ldap_pvt_thread_mutex_unlock( &slapi_printmessage_mutex );