198 Commits

Author SHA1 Message Date
Niclas Antti
cdea8aa7be mxs-1777: maxutils additions
Adding classes for calculating averages. Update StopWatch to C++11.
2018-09-05 17:05:06 +03:00
Markus Mäkelä
0afcfd7719
Link maxbase tests against rt
The logging requires it.
2018-08-31 09:32:07 +03:00
Johan Wikman
e2ba7151b7 MXS-2008 Enforce right initialization of maxbase
Now maxbase can only be initialized via maxbase::init().
2018-08-21 14:35:51 +03:00
Niclas Antti
24ab3c099c Move top of the file "#pragma once" to after the following comment (swap them). If the comment is a BPL update it to the latest one 2018-08-21 13:13:15 +03:00
Johan Wikman
e852dcacdd MXS-2008 Provide single entrypoint for initializing maxbase
Everything of maxbase can now be initialized by a call to

    maxbase_init();

(from a C-program) or

    maxbase::init();

from a C++-program and finalized with calls to either
maxbase_finish() or maxbase::finish(). Creating an instance
maxbase::MaxBase will take care of both operations.
2018-08-21 10:02:39 +03:00
Johan Wikman
88f1795412 MXS-2008 Move Worker and MessageQueue to maxbase 2018-08-21 10:02:39 +03:00
Markus Mäkelä
355768c564
Add overloads to dump_stacktrace
Using a function while debugging helps to see where various functions are
called from.
2018-08-20 13:56:59 +03:00
Markus Mäkelä
0685276764
Use correct functions in maxutils CMake files
The headers and the static library were installed unconditionally.
2018-08-20 13:56:58 +03:00
Johan Wikman
40a5ae81c7 MXS-2008 Store worker as MXB_WORKER* and not void* 2018-08-20 11:15:14 +03:00
Johan Wikman
e0cb11151f MXS-2008 Move maxscale/worker.h to maxbase/worker.h 2018-08-20 11:15:14 +03:00
Johan Wikman
932956d5f6 MXS-2008 Add maxbase/poll.[h|hh]
Remove maxscale/poll_core.h
2018-08-20 11:15:14 +03:00
Johan Wikman
aaad63ee5e MXS-2008 Move content of maxscale/platform.h to maxbase/cdefs.h
No good reason for keeping that platform adjustments anywhere
else but in cdefs.h.
2018-08-20 11:15:14 +03:00
Markus Mäkelä
9510a3ae1a
Use normal asserts in log.cc
The logger can't use the asserts that log messages as it introduces a
cyclical dependency on the logger itself.
2018-08-17 18:09:51 +03:00
Johan Wikman
9b199cfb50 Remove duplicate CMakeLists.txt entry
maxutils/maxbase/src/test/CMakeLists.txt
2018-08-17 16:21:58 +03:00
Johan Wikman
b82822a4b0 MXS-2017 Move maxscale::Semaphore to maxbase::Semaphore 2018-08-17 15:57:44 +03:00
Johan Wikman
d8255d0cac MXS-2017 Move maxscale::Semaphore to maxbase::Semaphore 2018-08-17 15:53:54 +03:00
Markus Mäkelä
25c81b118d
Rename conflicting test 2018-08-17 15:02:03 +03:00
Johan Wikman
c7a6d75ab9 MXS-2014 Address review issues 2018-08-17 10:59:37 +03:00
Johan Wikman
15bf481120 MXS-2014 Allow the header and footer to be adjusted 2018-08-17 10:59:37 +03:00
Johan Wikman
4388b8517e MXS-2014 Use standard assert in Logger 2018-08-17 10:59:37 +03:00
Johan Wikman
cfdfff46ae MXS-2014 Add skeleton test for mxb::Log 2018-08-17 10:59:37 +03:00
Johan Wikman
12e8f28907 MXS-2014 Add mxb::Log class for convenience
In tests, the log can now be setup as

    int main()
    {
        mxb::Log log;
        ...
    }

That will initialize the log so that it logs to a file called
<program-name>.log in the current directory and finalize it
when the program exits.
2018-08-17 10:59:37 +03:00
Johan Wikman
be986d366a MXS-2014 Handle default OOM message properly 2018-08-17 10:59:37 +03:00
Johan Wikman
876cf7c86f MXS-2014 Temporarily fix broken token pasting 2018-08-16 11:24:01 +03:00
Johan Wikman
19684deb69 MXS-2014 Init and finish properly
If any part of initalization fails, no resources are held.
At finalization, release all resources.

Also re-implement recent changes made to log_manager.cc that
did not automatically move over to log.cc.
2018-08-16 11:09:30 +03:00
Johan Wikman
a586aa13c4 MXS-2014 Add proper OOM support
Not that I think it ever will be needed...
2018-08-16 09:59:43 +03:00
Johan Wikman
85b68c439a MXS-2014 Still more cleanup of maxbase/log.h 2018-08-16 09:59:43 +03:00
Johan Wikman
8ae2997c4e MXS-2014 Remove separate log_write() function 2018-08-16 09:59:43 +03:00
Johan Wikman
5b46d815e4 MXS-2014 Move message status checking into MessageRegistry 2018-08-16 09:59:43 +03:00
Johan Wikman
79b292dc39 MXS-2014 Additional cleanup of log.cc 2018-08-16 09:59:43 +03:00
Johan Wikman
5b70c7605c MXS-2014 Some cleanup of log.cc
Unused stuff removed and unit variables collected into this_unit
structure.
2018-08-16 09:59:43 +03:00
Johan Wikman
0c479b5d13 MXS-2014 Enable asserts in log.cc 2018-08-16 09:59:43 +03:00
Johan Wikman
6b6bbceb6e MXS-2014 Add maxbase/assert.h
Basically a copy of maxscale/debug.h, but with some name changes.

- ss_dassert      -> mxb_assert
- ss_info_dassert -> mxb_assert_message
- ss_debug        -> MXB_AT_DEBUG
2018-08-16 09:59:43 +03:00
Johan Wikman
52e6e10e28 MXS-2014 Remove duplicate function
Two functions that essentially did the same thing, but had
slightly different name.
2018-08-16 09:58:00 +03:00
Johan Wikman
b4912a942f MXS-2014 Add missing MXB_[BEGIN|END]_DECLS 2018-08-16 09:58:00 +03:00
Johan Wikman
a191ed85a2 MXS-2014 Expose everything needed by the MaxScale log manager 2018-08-16 09:58:00 +03:00
Johan Wikman
1a6eb8165a MXS-2014 Add log.[h|cc] to maxbase
Almost a verbatim copy of log_manager.[h|cc] with mxs changed
to mxb. The changes allow the MaxScale log manager to be moved
on top of this implementation.
2018-08-16 09:58:00 +03:00
Johan Wikman
17418572f9 MXS-2014 Move maxscale/jansson.h to maxbase/jansson.h 2018-08-16 09:58:00 +03:00
Markus Mäkelä
be4f9125f0
Fix mxb_strerror
The function should not be an inline function with a static variable. This
appears to cause problems on at least Debian Wheezy and is likely to cause
odd behavior on other platforms.

Also renamed the file to <maxbase/string.h> to better mirror how the
<string.h> file behaves.
2018-08-15 14:58:46 +03:00
Johan Wikman
f3f802cabe MXS-2008 Move maxscale/atomic.h to maxbase/atomic.h 2018-08-15 08:44:39 +03:00
Johan Wikman
d53bc9d3be MXS-2008 Move maxscale/semaphore.h to maxbase/semaphore.h 2018-08-15 08:41:45 +03:00
Markus Mäkelä
c543525c1b
MXS-2005: Move Logger into maxutils
Moved the logger into the maxutils library as it is a generic
utility. Also moved mxs_strerror into it as it depends on it.
2018-08-14 14:57:34 +03:00
Johan Wikman
cc0299aee6 Update change date of 2.3 2018-06-25 10:07:52 +03:00
Markus Mäkelä
c32e6a7c3f
Add stacktrace generation to maxbase
The stacktrace generation is now a part of the maxbase library. The code
is the same code that was previously defined in gateway.cc as a part of
MaxScale.
2018-06-22 13:59:57 +03:00
Markus Mäkelä
7254a7c525
Make maxutils a standalone library
The only way to cleanly separate the maxutils library from the MaxScale
CMake project is to make it a standalone CMake project. With the help of
ExternalProject, it should be relatively easy to use.
2018-06-22 13:59:57 +03:00
Johan Wikman
9c6c0a4d95 Add common headers to maxbase
To be included first in all headers. Defined and included common
ground and provides a place when one can affect all code.
2018-06-20 09:53:19 +03:00
Niclas Antti
d2e1cfdf4e MXS-1777 fix CMakeLists.txt for utility library
Last minute directory changes were not fully applied in CMakeLists.txt
2018-06-18 15:27:44 +03:00
Niclas Antti
2514c99d9e MXS-1777 Create new utility library
The purpose of this library is to create a utility library that is not
dependent on maxscale for use in both maxscale and system test, and
possibly other apps. As time permits general purpose utilities from
maxscale-common can be moved to the new library.

Here are answers to questions you may have:
- A top level directory "maxutils" contains the libraries. The current
  structure is simply maxutils/maxbase. Each library has an 'include' and
  a 'scr' directory where public headers exist in 'include'
- Code is in a namespace with the same name as the directory.
- Headers are included like this: `#include <maxbase/stopwatch.hh>`
- In case the library is published on its own, the include directives stay
  the same (headers would be in /usr/include/maxutil, for example).
- I am not advocating many small libraries. But if some larger library
  is written, say a general purpose statemachine, it would not pollute
  util/maxutil but go to util/maxsm.
  Another example: Worker. It is a larger concept, but used so widely in
  code that it could very well live in maxutil.

NOTE: this was previously Review Request #6245.
2018-06-15 12:05:57 +03:00