1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
5 * Author: Phil Schwan <phil@clusterfs.com>
7 * This file is part of Portals, http://www.sf.net/projects/sandiaportals/
9 * Portals is free software; you can redistribute it and/or
10 * modify it under the terms of version 2.1 of the GNU Lesser General
11 * Public License as published by the Free Software Foundation.
13 * Portals is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Portals; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 int smp_processor_id = 1;
30 char debug_file_path[1024] = "/tmp/lustre-log";
31 char debug_file_name[1024];
34 int portals_do_debug_dumplog(void *arg)
36 printf("Look in %s\n", debug_file_name);
41 void portals_debug_print(void)
47 void portals_debug_dumplog(void)
49 printf("Look in %s\n", debug_file_name);
54 int portals_debug_init(unsigned long bufsize)
56 debug_file_fd = stdout;
60 int portals_debug_cleanup(void)
62 return 0; //close(portals_debug_fd);
65 int portals_debug_clear_buffer(void)
70 int portals_debug_mark_buffer(char *text)
73 fprintf(debug_file_fd, "*******************************************************************************\n");
74 fprintf(debug_file_fd, "DEBUG MARKER: %s\n", text);
75 fprintf(debug_file_fd, "*******************************************************************************\n");
80 int portals_debug_copy_to_user(char *buf, unsigned long len)
85 /* FIXME: I'm not very smart; someone smarter should make this better. */
87 portals_debug_msg (int subsys, int mask, char *file, char *fn, int line,
88 const char *format, ...)
96 /* NB since we pass a non-zero sized buffer (at least) on the first
97 * print, we can be assured that by the end of all the snprinting,
98 * we _do_ have a terminated buffer, even if our message got truncated.
101 gettimeofday(&tv, NULL);
103 nob += fprintf(debug_file_fd,
104 "%02x:%06x:%d:%lu.%06lu ",
105 subsys >> 24, mask, smp_processor_id,
106 tv.tv_sec, tv.tv_usec);
108 nob += fprintf(debug_file_fd,
109 "(%s:%d:%s() %d+%ld): ",
111 8192 - ((unsigned long)&flags & 8191UL));
113 va_start (ap, format);
114 nob += fprintf(debug_file_fd, format, ap);