blob: 73616b145a725fac2bb656eff8e46991ebfb878b [file] [log] [blame] [raw]
/*
* Copyright (C) 2000-2008, Parallels, Inc. 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, "", 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. */
int verbose; /**< Console verbosity. */
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 CT 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);
void set_log_verbose(int level);
#endif