Blame usr/log.h

Packit eace71
/*
Packit eace71
 * iSCSI Safe Logging and Tracing Library
Packit eace71
 *
Packit eace71
 * Copyright (C) 2004 Dmitry Yusupov, Alex Aizman
Packit eace71
 * maintained by open-iscsi@googlegroups.com
Packit eace71
 *
Packit eace71
 * circular buffer code based on log.c from dm-multipath project
Packit eace71
 *
Packit eace71
 * heavily based on code from log.c:
Packit eace71
 *   Copyright (C) 2002-2003 Ardis Technolgies <roman@ardistech.com>,
Packit eace71
 *   licensed under the terms of the GNU GPL v2.0,
Packit eace71
 *
Packit eace71
 * This program is free software; you can redistribute it and/or modify
Packit eace71
 * it under the terms of the GNU General Public License as published
Packit eace71
 * by the Free Software Foundation; either version 2 of the License, or
Packit eace71
 * (at your option) any later version.
Packit eace71
 *
Packit eace71
 * This program is distributed in the hope that it will be useful, but
Packit eace71
 * WITHOUT ANY WARRANTY; without even the implied warranty of
Packit eace71
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Packit eace71
 * General Public License for more details.
Packit eace71
 *
Packit eace71
 * See the file COPYING included with this distribution for more details.
Packit eace71
 */
Packit eace71
Packit eace71
#ifndef LOG_H
Packit eace71
#define LOG_H
Packit eace71
Packit eace71
#include <stdarg.h>
Packit eace71
#include <sys/types.h>
Packit eace71
#include "iscsid.h"
Packit eace71
Packit eace71
union semun {
Packit eace71
	int val;
Packit eace71
	struct semid_ds *buf;
Packit eace71
	unsigned short int *array;
Packit eace71
	struct seminfo *__buf;
Packit eace71
};
Packit eace71
#include <sys/sem.h>
Packit eace71
Packit eace71
#define DEFAULT_AREA_SIZE 16384
Packit eace71
#define MAX_MSG_SIZE 256
Packit eace71
Packit eace71
extern int log_level;
Packit eace71
Packit eace71
struct logmsg {
Packit eace71
	short int prio;
Packit eace71
	void *next;
Packit eace71
	char *str;
Packit eace71
};
Packit eace71
Packit eace71
struct logarea {
Packit eace71
	int shmid;
Packit eace71
	int shmid_msg;
Packit eace71
	int shmid_buff;
Packit eace71
	int empty;
Packit eace71
	void *head;
Packit eace71
	void *tail;
Packit eace71
	void *start;
Packit eace71
	void *end;
Packit eace71
	char *buff;
Packit eace71
	struct sembuf ops[1];
Packit eace71
	int semid;
Packit eace71
	union semun semarg;
Packit eace71
};
Packit eace71
Packit eace71
struct logarea *la;
Packit eace71
Packit eace71
extern int log_init(char *program_name, int size,
Packit eace71
	void (*func)(int prio, void *priv, const char *fmt, va_list ap),
Packit eace71
	void *priv);
Packit eace71
extern void log_close (pid_t pid);
Packit eace71
extern void dump_logmsg (void *);
Packit eace71
extern void log_info(const char *fmt, ...)
Packit eace71
	__attribute__ ((format (printf, 1, 2)));
Packit eace71
extern void log_warning(const char *fmt, ...)
Packit eace71
	__attribute__ ((format (printf, 1, 2)));
Packit eace71
extern void log_error(const char *fmt, ...)
Packit eace71
	__attribute__ ((format (printf, 1, 2)));
Packit eace71
extern void log_debug(int level, const char *fmt, ...)
Packit eace71
	__attribute__ ((format (printf, 2, 3)));
Packit eace71
Packit eace71
extern void log_do_log_daemon(int prio, void *priv, const char *fmt, va_list ap);
Packit eace71
extern void log_do_log_std(int prio, void *priv, const char *fmt, va_list ap);
Packit eace71
Packit eace71
#endif	/* LOG_H */