mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
Refactored formatters and updated the the writers a bit.
- Formatters have been abstracted similarly to readers and writers now. - The Ascii writer has a new option for writing out logs as JSON. - The Ascii writer now has all options availble as per-filter options as well as global.
This commit is contained in:
parent
83ec05bb4a
commit
a56c343715
25 changed files with 750 additions and 428 deletions
62
src/threading/formatters/Ascii.h
Normal file
62
src/threading/formatters/Ascii.h
Normal file
|
@ -0,0 +1,62 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#ifndef THREADING_FORMATTERS_ASCII_H
|
||||
#define THREADING_FORMATTERS_ASCII_H
|
||||
|
||||
#include "../Formatter.h"
|
||||
|
||||
namespace threading { namespace formatter {
|
||||
|
||||
class Ascii : public Formatter {
|
||||
public:
|
||||
/**
|
||||
* A struct to pass the necessary configuration values to the
|
||||
* Ascii module on initialization.
|
||||
*/
|
||||
struct SeparatorInfo
|
||||
{
|
||||
string separator; // Separator between columns
|
||||
string set_separator; // Separator between set elements.
|
||||
string unset_field; // String marking an unset field.
|
||||
string empty_field; // String marking an empty (but set) field.
|
||||
|
||||
/**
|
||||
* Constructor that leaves separators etc unset to dummy
|
||||
* values. Useful if you use only methods that don't need any
|
||||
* of them, like StringToAddr, etc.
|
||||
*/
|
||||
SeparatorInfo();
|
||||
|
||||
/**
|
||||
* Constructor that defines all the configuration options.
|
||||
* Use if you need either ValToODesc or EntryToVal.
|
||||
*/
|
||||
SeparatorInfo(const string& separator, const string& set_separator, const string& unset_field, const string& empty_field);
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param t The thread that uses this class instance. The class uses
|
||||
* some of the thread's methods, e.g., for error reporting and
|
||||
* internal formatting.
|
||||
*
|
||||
* @param info SeparatorInfo structure defining the necessary
|
||||
* separators.
|
||||
*/
|
||||
Ascii(threading::MsgThread* t, const SeparatorInfo info);
|
||||
virtual ~Ascii();
|
||||
|
||||
virtual bool Describe(ODesc* desc, threading::Value* val) const;
|
||||
virtual bool Describe(ODesc* desc, threading::Value* val, const string& name) const;
|
||||
virtual bool Describe(ODesc* desc, int num_fields, const threading::Field* const * fields,
|
||||
threading::Value** vals) const;
|
||||
virtual threading::Value* ParseValue(string s, string name, TypeTag type, TypeTag subtype = TYPE_ERROR) const;
|
||||
|
||||
private:
|
||||
SeparatorInfo separators;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif /* THREADING_FORMATTERS_ASCII_H */
|
Loading…
Add table
Add a link
Reference in a new issue