Revert "Change build option - IP only"
[platform/upstream/iotivity.git] / resource / oc_logger / include / oc_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 __OC_LOGGER_TYPES_H_2024_09_5
22  #define __OC_LOGGER_TYPES_H_2024_09_5
23
24 #include <stddef.h>
25
26 #ifdef __cplusplus
27  extern "C" {
28 #endif
29
30  typedef enum
31  {
32      OC_LOG_MIN_VAL__   = -1,
33      OC_LOG_ALL         = 0,
34      OC_LOG_FATAL,
35      OC_LOG_ERROR,
36      OC_LOG_WARNING,
37      OC_LOG_INFO,
38      OC_LOG_DEBUG,
39      OC_LOG_DISABLED,
40      OC_LOG_MAX_VAL__
41  } oc_log_level;
42
43 typedef struct _oc_log_ctx
44 {
45  void*                  ctx;
46
47  oc_log_level           log_level;
48
49  char*                  module_name;
50
51  /* Required interface: */
52  int  (*init)           (struct _oc_log_ctx *, void *);
53  void (*destroy)        (struct _oc_log_ctx *);
54  void (*flush)          (struct _oc_log_ctx *);
55  void (*set_level)      (struct _oc_log_ctx *, const int);
56  size_t (*write_level)  (struct _oc_log_ctx *, const int, const char *);
57  int  (*set_module)     (struct _oc_log_ctx *, const char *);
58
59  /* Optional interface (if one is implemented, all must be implemented): */
60  int (*lock)            (struct _oc_log_ctx *);
61  int (*unlock)          (struct _oc_log_ctx *);
62  int (*try_lock)        (struct _oc_log_ctx *);
63  int (*locked_destroy)  (struct _oc_log_ctx *);
64
65 } oc_log_ctx_t;
66
67 /* Notice that these are all passed the /top level/ ctx-- it's "public" with respect to
68 these functions, they have full access to fiddle with the structure all they want (but,
69 generally should avoid doing that); I could certainly be convinced to go the other direction,
70 and have most functions only take the inner context: */
71 typedef int    (*oc_log_init_t)          (oc_log_ctx_t *, void *);
72 typedef void   (*oc_log_destroy_t)       (oc_log_ctx_t *);
73 typedef void   (*oc_log_flush_t)         (oc_log_ctx_t *);
74 typedef void   (*oc_log_set_level_t)     (oc_log_ctx_t *, const int);
75 typedef size_t (*oc_log_write_level_t)   (oc_log_ctx_t *, const int, const char *);
76 typedef int    (*oc_log_set_module_t)    (oc_log_ctx_t *, const char *);
77 typedef int    (*oc_log_lock_t)          (oc_log_ctx_t *);
78 typedef int    (*oc_log_unlock_t)        (oc_log_ctx_t *);
79 typedef int    (*oc_log_try_lock_t)      (oc_log_ctx_t *);
80
81 #ifdef __cplusplus
82  } // extern "C"
83 #endif
84
85 #endif
86