1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef LIB_ZX_DEBUGLOG_H_
6 #define LIB_ZX_DEBUGLOG_H_
7 
8 #include <lib/zx/handle.h>
9 #include <lib/zx/object.h>
10 #include <lib/zx/resource.h>
11 
12 namespace zx {
13 
14 class debuglog : public object<debuglog> {
15 public:
16     static constexpr zx_obj_type_t TYPE = ZX_OBJ_TYPE_LOG;
17 
18     constexpr debuglog() = default;
19 
debuglog(zx_handle_t value)20     explicit debuglog(zx_handle_t value) : object(value) {}
21 
debuglog(handle && h)22     explicit debuglog(handle&& h) : object(h.release()) {}
23 
debuglog(debuglog && other)24     debuglog(debuglog&& other) : object(other.release()) {}
25 
26     debuglog& operator=(debuglog&& other) {
27         reset(other.release());
28         return *this;
29     }
30 
31     static zx_status_t create(const resource& resource, uint32_t options, debuglog* result);
32 
write(uint32_t options,const void * buffer,size_t buffer_size)33     zx_status_t write(uint32_t options, const void* buffer, size_t buffer_size) const {
34         return zx_debuglog_write(get(), options, buffer, buffer_size);
35     }
36 
read(uint32_t options,void * buffer,size_t buffer_size)37     zx_status_t read(uint32_t options, void* buffer, size_t buffer_size) const {
38         return zx_debuglog_read(get(), options, buffer, buffer_size);
39     }
40 };
41 
42 using unowned_debuglog = unowned<debuglog>;
43 
44 } // namespace zx
45 
46 #endif  // LIB_ZX_DEBUGLOG_H_
47