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 static ldap_pvt_thread_mutex_t PrintMessage_mutex;
30 static int PrintMessage_mutex_inited = 0;
35 if (PrintMessage_mutex_inited == 0) {
36 PrintMessage_mutex_inited = 1;
37 ldap_pvt_thread_mutex_init(&PrintMessage_mutex);
59 fmt = (char*)ch_calloc(strlen(subsystem) + strlen(tmpFmt) + 3, 1);
60 sprintf(fmt, "%s: %s", subsystem, tmpFmt);
63 ldap_pvt_thread_mutex_lock( &PrintMessage_mutex ) ;
65 /* for now, we log all severities */
67 fp = fopen( LDAP_RUNDIR LDAP_DIRSEP "errors", "a" );
69 fp = fopen( "errors", "a" );
72 while ( lockf(fileno(fp), F_LOCK, 0 ) != 0 ) {}
75 ltm = localtime( ¤tTime );
76 strftime( timeStr, sizeof(timeStr), "%x %X ", ltm );
78 for (p = fmt; *p; p++) {
80 fprintf(fp, "%c", *p);
85 ival = va_arg( arglist, int);
86 fprintf(fp, "%d", ival);
89 for (sval = va_arg(arglist, char *); *sval; sval++)
90 fprintf(fp, "%c", *sval);
93 fprintf(fp, "%c", *p);
101 lockf( fileno(fp), F_ULOCK, 0 );
106 int save_errno = (int)errno;
114 ldap_pvt_thread_mutex_unlock( &PrintMessage_mutex );