mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Merge remote-tracking branch 'origin/topic/seth/json-formatter'
* origin/topic/seth/json-formatter: Updating a couple of tests. Expanded support for modifying the timestamp format in the JSON formatter. Ascii input reader now supports all config options per-input stream. Added an option to the JSON formatter to use ISO 8601 for timestamps. Refactored formatters and updated the the writers a bit. Includes some minor bugfixes and cleanup at various places, including in old code.
This commit is contained in:
commit
ff261ea626
34 changed files with 1038 additions and 540 deletions
36
src/threading/formatters/JSON.h
Normal file
36
src/threading/formatters/JSON.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#ifndef THREADING_FORMATTERS_JSON_H
|
||||
#define THREADING_FORMATTERS_JSON_H
|
||||
|
||||
#include "../Formatter.h"
|
||||
|
||||
namespace threading { namespace formatter {
|
||||
|
||||
/**
|
||||
* A thread-safe class for converting values into a JSON representation
|
||||
* and vice versa.
|
||||
*/
|
||||
class JSON : public Formatter {
|
||||
public:
|
||||
enum TimeFormat {
|
||||
TS_EPOCH, // Doubles that represents seconds from the UNIX epoch.
|
||||
TS_ISO8601, // ISO 8601 defined human readable timestamp format.
|
||||
TS_MILLIS // Milliseconds from the UNIX epoch. Some consumers need this (e.g., elasticsearch).
|
||||
};
|
||||
|
||||
JSON(threading::MsgThread* t, TimeFormat tf);
|
||||
virtual ~JSON();
|
||||
|
||||
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:
|
||||
TimeFormat timestamps;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif /* THREADING_FORMATTERS_JSON_H */
|
Loading…
Add table
Add a link
Reference in a new issue