File: log.h

package info (click to toggle)
ippl 1.4.14-12.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 452 kB
  • ctags: 244
  • sloc: ansic: 1,649; sh: 794; yacc: 434; lex: 160; makefile: 93
file content (56 lines) | stat: -rw-r--r-- 1,642 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 *  log.h - Logging mechanism
 *
 *  Copyright (C) 1999 Hugo Haas
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef LOG_H
#define LOG_H

/** Defaults **/

/* Logging level */
#include <sys/syslog.h>
#define LOGLEVEL LOG_NOTICE

/* Structure holding info for logging */

struct loginfo {
  void (*log)(int, char *, ...);
  int level_or_fd; /* priority of the message for syslog / file descriptor */
  char *file;	/* log file to use (if any) */
  void (*open)(int *, const char *);
  void (*close)(int *, const char *);
};

void init_loginfo(struct loginfo *li);
void log_in_file(struct loginfo *li, char *filename);

/* Dummy functions */
void dummy_open(int *fd, const char *filename);
void dummy_close(int *fd, const char *filename);

void syslog_open(int *level, const char *filename);

void file_open(int *fd, const char *filename);
void file_close(int *fd, const char *filename);

#define BUFFER_SIZE 1024

void filedesc_log(int fd, char *format, ...);

#endif