#define F_OK 0
#endif
+char *threadname();
+
static int serverLogFD = -1;
#include <stdarg.h>
int LogLevel;
+int mrafsStyleLogs = 0;
+int printLocks = 0;
+static char ourName[MAXPATHLEN];
+
+void WriteLogBuffer(buf,len)
+ char *buf;
+ afs_uint32 len;
+{
+ LOCK_SERVERLOG();
+ if (serverLogFD > 0)
+ write(serverLogFD, buf, len);
+ UNLOCK_SERVERLOG();
+}
/* VARARGS1 */
void FSLog (const char *format, ...)
char tbuffer[1024];
char *info;
int len;
+ int i;
+ char *name;
currenttime = time(0);
timeStamp = afs_ctime(¤ttime, tbuffer, sizeof(tbuffer));
timeStamp[24] = ' '; /* ts[24] is the newline, 25 is the null */
info = &timeStamp[25];
+ if (mrafsStyleLogs) {
+ name = threadname();
+ sprintf(info, "[%s] ", name);
+ info += strlen(info);
+ }
+
va_start(args, format);
(void) vsprintf(info, format, args);
va_end(args);
else {
LogLevel = 1;
}
+ printLocks = 2;
#if defined(AFS_PTHREAD_ENV)
DebugOn(LogLevel);
#else /* AFS_PTHREAD_ENV */
{
LogLevel = 0;
+ if (printLocks >0) --printLocks;
#if defined(AFS_PTHREAD_ENV)
DebugOn(LogLevel);
#else /* AFS_PTHREAD_ENV */
signal(signo, ResetDebug_Signal); /* on some platforms, this signal */
/* handler needs to be set again */
+ if (mrafsStyleLogs)
+ OpenLog((char *)&ourName);
} /*ResetDebug_Signal*/
*/
int tempfd;
char oldName[MAXPATHLEN];
+ struct timeval Start;
+ struct tm *TimeFields;
+ char FileName[MAXPATHLEN];
+
+ if (mrafsStyleLogs) {
+ TM_GetTimeOfDay(&Start, 0);
+ TimeFields = localtime(&Start.tv_sec);
+ if (fileName) {
+ if (strncmp(fileName, (char *)&ourName, strlen(fileName)))
+ strcpy((char *)&ourName, (char *) fileName);
+ }
+ sprintf(FileName, "%s.%d%02d%02d%02d%02d%02d", ourName,
+ TimeFields->tm_year + 1900, TimeFields->tm_mon + 1,
+ TimeFields->tm_mday, TimeFields->tm_hour,
+ TimeFields->tm_min, TimeFields->tm_sec);
+ rename (fileName, FileName); /* don't check error code */
+ tempfd = open(fileName, O_WRONLY | O_TRUNC | O_CREAT, 0666);
+ } else {
+ strcpy(oldName, fileName);
+ strcat(oldName, ".old");
- strcpy(oldName, fileName);
- strcat(oldName, ".old");
+ /* don't check error */
+ renamefile(fileName, oldName);
+ tempfd = open(fileName, O_WRONLY|O_TRUNC|O_CREAT, 0666);
+ }
- /* don't check error */
- renamefile(fileName, oldName);
- tempfd = open(fileName, O_WRONLY|O_TRUNC|O_CREAT, 0666);
if(tempfd < 0)
{
printf("Unable to open log file %s\n", fileName);