Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 157 lines (142 sloc) 5.761 kb
d8ff4974 »
2012-08-03 config- and logging-related enhancements in C-land
1 // -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil -*-
2 // vim: set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
3
c33e3610 »
2012-08-10 Update license headers
4 /*************************************************************************
9357f434 »
2012-08-13 Merge remote-tracking branch origin/testing into team/trouble
5 * Copyright 2009-2012 Eucalyptus Systems, Inc.
c33e3610 »
2012-08-10 Update license headers
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 3 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see http://www.gnu.org/licenses/.
18 *
19 * Please contact Eucalyptus Systems, Inc., 6755 Hollister Ave., Goleta
20 * CA 93117, USA or visit http://www.eucalyptus.com/licenses/ if you need
21 * additional information or have any questions.
9357f434 »
2012-08-13 Merge remote-tracking branch origin/testing into team/trouble
22 *
23 * This file may incorporate work covered under the following copyright
24 * and permission notice:
25 *
26 * Software License Agreement (BSD License)
27 *
28 * Copyright (c) 2008, Regents of the University of California
29 * All rights reserved.
30 *
31 * Redistribution and use of this software in source and binary forms,
32 * with or without modification, are permitted provided that the
33 * following conditions are met:
34 *
35 * Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 *
38 * Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer
40 * in the documentation and/or other materials provided with the
41 * distribution.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
46 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
47 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
48 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
49 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
51 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
52 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
53 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
54 * POSSIBILITY OF SUCH DAMAGE. USERS OF THIS SOFTWARE ACKNOWLEDGE
55 * THE POSSIBLE PRESENCE OF OTHER OPEN SOURCE LICENSED MATERIAL,
56 * COPYRIGHTED MATERIAL OR PATENTED MATERIAL IN THIS SOFTWARE,
57 * AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
58 * IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA,
59 * SANTA BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY,
60 * WHICH IN THE REGENTS' DISCRETION MAY INCLUDE, WITHOUT LIMITATION,
61 * REPLACEMENT OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO
62 * IDENTIFIED, OR WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT
63 * NEEDED TO COMPLY WITH ANY SUCH LICENSES OR RIGHTS.
c33e3610 »
2012-08-10 Update license headers
64 ************************************************************************/
d8ff4974 »
2012-08-03 config- and logging-related enhancements in C-land
65
66 #ifndef LOG_H
67 #define LOG_H
68
86c522d0 »
2012-10-05 Two new faults in C-land, symlinked work/cache ok
69 #include "ipc.h" // sem
70
c2783912 »
2012-09-26 Logging enhancements for C-based components.
71 extern __thread const char * _log_curr_method;
72 extern __thread const char * _log_curr_file;
73 extern __thread int _log_curr_line;
74
75 #define _EUCA_CONTEXT_SETTER (_log_curr_method=__FUNCTION__,\
76 _log_curr_file=__FILE__,\
77 _log_curr_line=__LINE__)
78
79 #define EUCAALL 0
80 #define EUCAEXTREME (_EUCA_CONTEXT_SETTER, 1)
81 #define EUCATRACE (_EUCA_CONTEXT_SETTER, 2)
82 #define EUCADEBUG (_EUCA_CONTEXT_SETTER, 3)
83 #define EUCAINFO (_EUCA_CONTEXT_SETTER, 4)
84 #define EUCAWARN (_EUCA_CONTEXT_SETTER, 5)
85 #define EUCAERROR (_EUCA_CONTEXT_SETTER, 6)
86 #define EUCAFATAL (_EUCA_CONTEXT_SETTER, 7)
87 #define EUCAOFF 8
d8ff4974 »
2012-08-03 config- and logging-related enhancements in C-land
88
89 static char * log_level_names [] = {
90 "ALL",
c2783912 »
2012-09-26 Logging enhancements for C-based components.
91 "EXTREME",
d8ff4974 »
2012-08-03 config- and logging-related enhancements in C-land
92 "TRACE",
93 "DEBUG",
94 "INFO",
95 "WARN",
96 "ERROR",
97 "FATAL",
98 "OFF"
99 };
100
c2783912 »
2012-09-26 Logging enhancements for C-based components.
101 /////////////////////// prefix format
102 // T = timestamp
103 // L = loglevel
104 // p = PID
105 // t = thread id (same as PID in CC)
106 // m = method
107 // F = file:line_no
108 //
109 // p,t,m,F may be followed by (-)NNN,
110 // '-' means left-justified
111 // and NNN is max field size
112 /////////////////////////////////////
113 static char * log_level_prefix [] = {
114 "",
e23c33af »
2012-10-08 Log-line tweaks in C and Java, for consistency.
115 "T L t9 m-24 F-33 | ", // EXTREME
116 "T L t9 m-24 | ", // TRACE
117 "T L t9 m-24 | ", // DEBUG
118 "T L | ", // INFO
119 "T L | ", // WARN
120 "T L | ", // ERROR
121 "T L | ", // FATAL
c2783912 »
2012-09-26 Logging enhancements for C-based components.
122 ""
123 };
124
c253d3fe »
2012-08-09 move PRINTF() style wrapper macros for logprintf() from misc.h to log.h
125 #ifdef DEBUG
126 #define PRINTF(a) logprintf a
127 #else
128 #define PRINTF(a)
129 #endif
130
131 #ifdef DEBUG1
132 #define PRINTF1(a) logprintf a
133 #else
134 #define PRINTF1(a)
135 #endif
136
137 #ifdef DEBUGXML
138 #define PRINTF_XML(a) logprintf a
139 #else
140 #define PRINTF_XML(a)
141 #endif
142
d8ff4974 »
2012-08-03 config- and logging-related enhancements in C-land
143 int log_level_int(const char *level);
144 void log_params_set(int log_level_in, int log_roll_number_in, long log_max_size_bytes_in);
145 void log_params_get(int *log_level_out, int *log_roll_number_out, long *log_max_size_bytes_out);
146 int log_file_set(const char * file);
c2783912 »
2012-09-26 Logging enhancements for C-based components.
147 int log_prefix_set (const char * log_spec);
86c522d0 »
2012-10-05 Two new faults in C-land, symlinked work/cache ok
148 int log_sem_set (sem * s);
d8ff4974 »
2012-08-03 config- and logging-related enhancements in C-land
149 int logfile(char *file, int in_loglevel, int in_logrollnumber);
150 int logprintf(const char *format, ...);
151 int logprintfl(int level, const char *format, ...);
152 int logcat (int debug_level, const char * file_name);
153
154 void eventlog(char *hostTag, char *userTag, char *cid, char *eventTag, char *other);
155
156 #endif
Something went wrong with that request. Please try again.