package XAS::Lib::Log::Json;
our $VERSION = '0.01';
use XAS::Factory;
use XAS::Class
debug => 0,
version => $VERSION,
base => 'XAS::Base',
utils => ':validation level2sys
log',
codec => 'JSON',
accessors => 'spooler',
constants => 'HASHREF',
filesystem => 'Dir',
;
# note to self: Don't but $self->log->debug() statements in here
# it will produce a nice
'),
uc($args->{'priority'}),
$args->{'message'}
);
# create a logstash "json_event"
my $data = {
'@timestamp' => $args->{'datetime'}->strftime('%Y-%m-%dT%H:%M:%S
PC::JSON::Client;
our $VERSION = '0.02';
use XAS::Class
debug => 0,
version => $VERSION,
base => 'XAS::Lib::Net::Client',
utils => ':validation dotid',
codec => 'JSON',
constants => ':jsonrpc HASHREF',
;
use Data::Dumper;
# ----------------------------------------------------------------------
# Public Methods
# ---------------------------------------------------
$key =~ s/^-//;
$params->{$key} = $value;
}
my $packet = {
jsonrpc => RPC_JSON,
id => $p->{'id'},
method => $p->{'method'},
params => $pa
package XAS::Lib::RPC::JSON::Server;
our $VERSION = '0.04';
use POE;
use Try::Tiny;
use Set::Light;
use XAS::Class
debug => 0,
version => $VERSION,
base => 'XAS::Lib::Net::Server',
utils => ':validation dotid',
accessors => 'methods',
codec => 'JSON',
constants => 'HASH ARRAY :jsonrpc ARRAYREF HASHREF',
;
my $ERRORS = {
'-32700' => 'Parse Error',
'-3260
,
{ type => HASHREF }
]);
my $json;
my $alias = $self->alias;
$self->log->debug("$alias: entering process_response");
$json = $self->_rpc_result($ctx->{'id'}, $output);
Log::Console>
=item L<XAS::Lib::Log::File|XAS::Lib::Log::File>
=item L<XAS::Lib::Log::Json|XAS::Lib::Log::Json>
=item L<XAS::Lib::Log::Syslog|XAS::Lib::Log::Syslog>
=item L<XAS|XAS>
=back
=head1
Log::Console>
=item L<XAS::Lib::Log::File|XAS::Lib::Log::File>
=item L<XAS::Lib::Log::Json|XAS::Lib::Log::Json>
=item L<XAS::Lib::Log::Syslog|XAS::Lib::Log::Syslog>
=item L<XAS::Lib::Mixins::Bufop
|XAS::Lib::Process::Win32>
=item L<XAS::Lib::RPC::JSON::Client|XAS::Lib::RPC::JSON::Client>
=item L<XAS::Lib::RPC::JSON::Server|XAS::Lib::RPC::JSON::Server>
=item L<XAS::Lib::Service|XAS::Lib::Serv
ants
constant => {
# generic
LF => "\012",
CR => "\015",
# JSON RPC
RPC_JSON => '2.0',
RPC_DEFAULT_ADDRESS => '127.0.0.1',
RPC_DEFAULT_PORT
LOG_LEVELS => qr/info|warn|error|fatal|debug|trace/,
LOG_TYPES => qr/console|file|json|syslog/,
LOG_FACILITY => qr/auth|authpriv|cron|daemon|ftp|local[0-7]|lpr|mail|news|user|uuc
LOCK_DRIVERS => qr(Flom|Filesystem|Nolock|KeyedMutex),
},
exports => {
all => 'RPC_JSON RPC_DEFAULT_PORT RPC_DEFAULT_ADDRESS RPC_ERR_PARSE
RPC_ERR_REQ RPC_ERR_METHOD RPC_
lt the log is displayed on the console. Log
types can be one of the following "console", "file", "json" or "syslog".
=head2 --log-facility
What log facility class to use. This follows syslog convent
strings. Which means every string has a consistent EOL.
These strings may be formatted, such as JSON. This module inherits from
L<XAS::Lib::POE::Session|XAS::Lib::POE::Session>.
=head1 METHODS
=h
ion => $VERSION,
base => 'XAS::Singleton',
accessors => 'spooler',
codec => 'JSON',
utils => ':validation',
filesystem => 'Dir'
;
# -------------------------------------
y => $self->env->facility,
message => $message,
};
my $json = encode($data);
$self->spooler->write($json);
}
# ----------------------------------------------------------------
es the syslog
conventions.
=item B<XAS_LOG_TYPE>
The log type. This can be "console", "file", "json" or "syslog". Defaults
to "console"
=item B<XAS_ERR_THROWS>
The default error message type. Def
lid options
are "console", "file", "json" and "syslog'.
=head2 log_facility
This method will return the log facility class to use when writting to
syslog or json.
Example
$facility = $xas->lo
e => 'XAS::Lib::Net::Server',
mixin => 'XAS::Lib::Mixin::JSON::Server XAS::Lib::Mixins::Keepalive',
constants => ':jsonrpc',
vars => {
PARAMS => {
-port => { optional
ss = shift;
my $self = $class->SUPER::init(@_);
my $methods = ['echo'];
$self->init_json_server($methods);
return $self;
}
1;
__END__
=head1 NAME
XAS::xxx - A class for the XAS