| 301 |
ashish |
1 |
// Copyright (c) 2007-2008 Facebook
|
|
|
2 |
//
|
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
|
5 |
// You may obtain a copy of the License at
|
|
|
6 |
//
|
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
8 |
//
|
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
12 |
// See the License for the specific language governing permissions and
|
|
|
13 |
// limitations under the License.
|
|
|
14 |
//
|
|
|
15 |
// See accompanying file LICENSE or visit the Scribe site at:
|
|
|
16 |
// http://developers.facebook.com/scribe/
|
|
|
17 |
//
|
|
|
18 |
// @author Bobby Johnson
|
|
|
19 |
|
|
|
20 |
#ifndef SCRIBE_ENV
|
|
|
21 |
#define SCRIBE_ENV
|
|
|
22 |
|
|
|
23 |
#define DEFAULT_CONF_FILE_LOCATION "/usr/local/scribe/scribe.conf"
|
|
|
24 |
|
|
|
25 |
/*
|
|
|
26 |
* This file contains methods for handling tasks that depend
|
|
|
27 |
* on the environment in which this process is running.
|
|
|
28 |
* i.e. using scribe will not force the adoption of a particular
|
|
|
29 |
* system for monitoring or configuring services over the network.
|
|
|
30 |
*/
|
|
|
31 |
|
|
|
32 |
/*
|
|
|
33 |
* Debug logging
|
|
|
34 |
*/
|
|
|
35 |
#define LOG_OPER(format_string,...) \
|
|
|
36 |
{ \
|
|
|
37 |
time_t now; \
|
|
|
38 |
char dbgtime[26] ; \
|
|
|
39 |
time(&now); \
|
|
|
40 |
ctime_r(&now, dbgtime); \
|
|
|
41 |
dbgtime[24] = '\0'; \
|
|
|
42 |
fprintf(stderr,"[%s] " #format_string " \n", dbgtime,##__VA_ARGS__); \
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
/*
|
|
|
46 |
* Network based configuration and directory service
|
|
|
47 |
*/
|
|
|
48 |
|
|
|
49 |
class network_config {
|
|
|
50 |
public:
|
|
|
51 |
// gets a vector of machine/port pairs for a named service
|
|
|
52 |
// returns true on success
|
|
|
53 |
static bool getService(const std::string& serviceName,
|
|
|
54 |
const std::string& options,
|
|
|
55 |
server_vector_t& _return) {
|
|
|
56 |
return false;
|
|
|
57 |
}
|
|
|
58 |
};
|
|
|
59 |
|
|
|
60 |
|
|
|
61 |
/*
|
|
|
62 |
* Hash functions
|
|
|
63 |
*/
|
|
|
64 |
|
|
|
65 |
// You can probably find better hash functions than these
|
|
|
66 |
class integerhash {
|
|
|
67 |
public:
|
|
|
68 |
static uint32_t hash32(uint32_t key) {
|
|
|
69 |
return key;
|
|
|
70 |
}
|
|
|
71 |
};
|
|
|
72 |
|
|
|
73 |
class strhash {
|
|
|
74 |
public:
|
|
|
75 |
static uint32_t hash32(const char *s) {
|
|
|
76 |
return 0;
|
|
|
77 |
}
|
|
|
78 |
};
|
|
|
79 |
|
|
|
80 |
#endif // SCRIBE_ENV
|