2 * Copyright 1998-2002 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>
22 #include <ldap_config.h>
26 #include <ldap_pvt_thread.h>
28 /* Single threads access to routine */
29 ldap_pvt_thread_mutex_t slapi_printmessage_mutex;
30 const char *slapi_log_file = NULL;
31 int slapi_log_level = SLAPI_LOG_PLUGIN;
47 assert( subsystem != NULL );
48 assert( fmt != NULL );
50 ldap_pvt_thread_mutex_lock( &slapi_printmessage_mutex ) ;
52 /* for now, we log all severities */
53 if ( level <= slapi_log_level ) {
54 fp = fopen( slapi_log_file, "a" );
63 while ( lockf( fileno( fp ), F_LOCK, 0 ) != 0 ) {
68 ltm = localtime( ¤tTime );
69 strftime( timeStr, sizeof(timeStr), "%x %X", ltm );
72 fprintf( fp, " %s: ", subsystem );
73 vfprintf( fp, fmt, arglist );
74 if ( fmt[ strlen( fmt ) - 1 ] != '\n' ) {
79 lockf( fileno( fp ), F_ULOCK, 0 );
88 ldap_pvt_thread_mutex_unlock( &slapi_printmessage_mutex );