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