Subversion Repositories shark

Rev

Rev 393 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/*
20
 * Copyright (C) 1999 Massimiliano Giorgi
21
 *
22
 * This program is free software; you can redistribute it and/or modify
23
 * it under the terms of the GNU General Public License as published by
24
 * the Free Software Foundation; either version 2 of the License, or
25
 * (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
35
 *
36
 */
37
 
38
/*
395 giacomo 39
 * CVS :        $Id: printk.c,v 1.7 2004-01-12 18:26:38 giacomo Exp $
2 pj 40
 *
41
 * File:        $File$
395 giacomo 42
 * Revision:    $Revision: 1.7 $
43
 * Last update: $Date: 2004-01-12 18:26:38 $
2 pj 44
 */
45
 
46
#include <ll/i386/cons.h>
47
#include <ll/stdarg.h>
48
#include <ll/string.h>
49
#include <ll/stdio.h>
50
#include <kernel/log.h>
51
#include <kernel/func.h>
52
 
53
static int printklevel=0;
54
 
385 giacomo 55
#define NO_LEVEL 100
56
 
2 pj 57
static char *levelname[]={
58
  "emerg ",
59
  "alert ",
60
  "crit  ",
61
  "err   ",
62
  "warn  ",
63
  "notice",
64
  "info  ",
65
  "debug "
66
};
67
 
395 giacomo 68
int vprintk(int flag, char *fmt, va_list ap)
2 pj 69
{
395 giacomo 70
  static char buf[1024]; /* DANGER !!!!! */
2 pj 71
  int level;
72
 
385 giacomo 73
  level = NO_LEVEL;
74
  if (*fmt == '<' && *(fmt+2) == '>')
75
    level = *(fmt+1) - '0';
76
  if (level != NO_LEVEL) {
2 pj 77
    if (level<LOG_EMERG||level>LOG_DEBUG) level=LOG_INFO;
78
    fmt+=3;
79
  }
395 giacomo 80
 
2 pj 81
  if (level<=printklevel) return 0;
82
 
395 giacomo 83
  vksprintf(buf,(char*)fmt,ap);
2 pj 84
 
385 giacomo 85
  if (level != NO_LEVEL)
395 giacomo 86
    message("[%s] %s",levelname[level],buf);
385 giacomo 87
  else
395 giacomo 88
   message("%s",buf);
2 pj 89
 
90
  return 0;
91
}
92
 
93
int printk(const char *fmt, ...)
94
{
95
  va_list ap;
390 giacomo 96
  int res = 0;
2 pj 97
 
98
  va_start(ap, fmt);
99
  res=vprintk(0,(char *)fmt, ap);
100
  va_end(ap);
101
  return res;
102
}
103
 
104
int printkboot(const char *fmt, ...)
105
{
106
  va_list ap;
107
  int res;
108
 
109
  va_start(ap, fmt);
110
  res=vprintk(1,(char *)fmt, ap);
111
  va_end(ap);
112
  return res;
113
}