File: logger.h

package info (click to toggle)
vzctl 3.0.11-13
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 1,164 kB
  • ctags: 1,894
  • sloc: ansic: 14,655; sh: 2,744; makefile: 419
file content (70 lines) | stat: -rw-r--r-- 1,960 bytes parent folder | download | duplicates (2)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 *  Copyright (C) 2000-2006 SWsoft. All rights reserved.
 *
 *  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#ifndef _LOGGER_H_
#define _LOGGER_H_

#include <stdio.h>
#include "types.h"

#define	LOG_DATA	log_param g_log = {NULL, 0, 1, 0, "", 0};

/** Data structure for logging.
 */
typedef struct {
	FILE *fp;		/**< log file pointer. */
	int level;		/**< maximum logging level. */
	int enable;		/**< enable/disable logging. */
	int quiet;		/**< skip logging to stdout. */
	char prog[32];		/**< program name. */
	envid_t veid;
} log_param;

/** Print message to log file & stdout.
 *
 * @param log_level		message severity.
 * @param err_num		errno
 * @param format		fprintf format.
 */
void logger(int log_level, int err_num, const char *format, ...);

/** Change/set log file.
 *
 * @param file		file name.
 * @return		0 on success.
 */
int set_log_file(char *file);

/** Initialize logging.
 * 
 * @param file		log file.
 * @param veid		VPS id.
 * @param enable	enable/disable logging.
 * @param level		maximum logging level.
 * @param quiet		skip logging to stdout.
 * @param progname	program name.
 */
int init_log(char *file, envid_t veid, int enable, int level, int quiet,
	char *progname);

/** Close logging.
 */
void free_log();

void set_log_level(int level);

#endif