f372a4ced2d57e6cdc002b024d4ab50e348e0984
[platform/upstream/iotivity.git] / resource / csdk / connectivity / common / inc / oic_logger_types.h
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef __OIC_LOGGER_TYPES_H_
22 #define __OIC_LOGGER_TYPES_H_
23
24 #include <stddef.h>
25
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30
31 typedef enum
32 {
33     __OIC_LOG_MIN__ = -1,
34     OIC_LOG_ALL = 0,
35     OIC_LOG_FATAL,
36     OIC_LOG_ERROR,
37     OIC_LOG_WARNING,
38     OIC_LOG_INFO,
39     OIC_LOG_DEBUG,
40     OIC_LOG_DISABLED,
41     __OIC_LOG_MAX__
42 } oic_log_level;
43
44 typedef struct _oic_log_ctx
45 {
46     void* ctx;
47
48     oic_log_level log_level;
49
50     char* module_name;
51
52     /* Required interface: */
53     int (*init)(struct _oic_log_ctx *, void *);
54     void (*destroy)(struct _oic_log_ctx *);
55     void (*flush)(struct _oic_log_ctx *);
56     void (*set_level)(struct _oic_log_ctx *, const int);
57     size_t (*write_level)(struct _oic_log_ctx *, const int, const char *);
58     int (*set_module)(struct _oic_log_ctx *, const char *);
59
60     /* Optional interface (if one is implemented, all must be implemented): */
61     int (*lock)(struct _oic_log_ctx *);
62     int (*unlock)(struct _oic_log_ctx *);
63     int (*try_lock)(struct _oic_log_ctx *);
64     int (*locked_destroy)(struct _oic_log_ctx *);
65
66 } oic_log_ctx_t;
67
68 /* Notice that these are all passed the /top level/ ctx-- it's "public" with respect to
69  these functions, they have full access to fiddle with the structure all they want (but,
70  generally should avoid doing that); I could certainly be convinced to go the other direction,
71  and have most functions only take the inner context: */
72 typedef int (*oic_log_init_t)(oic_log_ctx_t *, void *);
73 typedef void (*oic_log_destroy_t)(oic_log_ctx_t *);
74 typedef void (*oic_log_flush_t)(oic_log_ctx_t *);
75 typedef void (*oic_log_set_level_t)(oic_log_ctx_t *, const int);
76 typedef size_t (*oic_log_write_level_t)(oic_log_ctx_t *, const int, const char *);
77 typedef int (*oic_log_set_module_t)(oic_log_ctx_t *, const char *);
78 typedef int (*oic_log_lock_t)(oic_log_ctx_t *);
79 typedef int (*oic_log_unlock_t)(oic_log_ctx_t *);
80 typedef int (*oic_log_try_lock_t)(oic_log_ctx_t *);
81
82 #ifdef __cplusplus
83 } // extern "C"
84 #endif
85
86 #endif