source: trunk/packages/vizservers/vtkvis/Trace.cpp @ 2263

Last change on this file since 2263 was 2100, checked in by ldelgass, 13 years ago

VTKVis server for 2D contour plots. Required modifications to vizservers build
to follow.

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (C) 2011, Purdue Research Foundation
4 *
5 * Author: ?
6 */
7
8#include <cstdio>
9#include <cstdarg>
10#include <cstring>
11#include <syslog.h>
12
13#include "Trace.h"
14
15using namespace Rappture::VtkVis;
16
17#define MSG_LEN 2047
18
19/**
20 * \brief Open syslog for writing
21 */
22void
23Rappture::VtkVis::InitLog()
24{
25    openlog("vtkvis", LOG_CONS | LOG_PERROR | LOG_PID,  LOG_USER);
26}
27
28/**
29 * \brief Close syslog
30 */
31void
32Rappture::VtkVis::CloseLog()
33{
34    closelog();
35}
36
37/**
38 * \brief Write a message to syslog
39 */
40void
41Rappture::VtkVis::LogMessage(int priority, const char *funcname,
42                             const char *path, int lineNum, const char* fmt, ...)
43{
44    char message[MSG_LEN + 1];
45    const char *s;
46    int length;
47    va_list lst;
48
49    va_start(lst, fmt);
50    s = strrchr(path, '/');
51    if (s == NULL) {
52        s = path;
53    } else {
54        s++;
55    }
56    if (priority & LOG_DEBUG) {
57        length = snprintf(message, MSG_LEN, "%s:%d(%s): ", s, lineNum, funcname);
58    } else {
59        length = snprintf(message, MSG_LEN, "%s:%d: ", s, lineNum);
60    }
61    length += vsnprintf(message + length, MSG_LEN - length, fmt, lst);
62    message[MSG_LEN] = '\0';
63
64    syslog(priority, message, length);
65}
66
67
Note: See TracBrowser for help on using the repository browser.