Log-FreeSWITCH-Line

 view release on metacpan or  search on metacpan

Line.pm  view on Meta::CPAN

	return $data;
}

1;

__END__

=pod

=encoding utf8

=head1 NAME

Log::FreeSWITCH::Line - FreeSWITCH log line parsing and serializing.

=head1 SYNOPSIS

 use Log::FreeSWITCH::Line qw(parse serialize);

 my $data_o = parse($data);
 my $data = serialize($data_o);

=head1 SUBROUTINES

=head2 C<parse>

 my $data_o = parse($data);

Parse FreeSWITCH log line.

Returns Log::FreeSWITCH::Line::Data object.

=head2 C<serialize>

 my $data = serialize($data_o);

Serialize Log::FreeSWITCH::Line::Data object to FreeSWITCH log line.

Returns string.

=head1 ERRORS

 parse():
         Cannot parse data.
                 Data: %s

 serialize():
         Serialize object must be 'Log::FreeSWITCH::Line::Data' object.

=head1 EXAMPLE1

=for comment filename=parse_log_line.pl

 use strict;
 use warnings;

 use Data::Printer;
 use Log::FreeSWITCH::Line qw(parse);

 # Log record.
 my $data = '2014-07-01 13:37:53.973562 [DEBUG] sofia.c:4045 inbound-codec-prefs [PCMA]';

 # Parse.
 my $data_o = parse($data);

 # Dump.
 p $data_o;

 # Output:
 # Log::FreeSWITCH::Line::Data  {
 #     Parents       Mo::Object
 #     public methods (0)
 #     private methods (1) : _datetime
 #     internals: {
 #         date        "2014-07-01",
 #         file        "sofia.c",
 #         file_line   4045,
 #         message     "inbound-codec-prefs [PCMA]",
 #         raw         "2014-07-01 13:37:53.973562 [DEBUG] sofia.c:4045 inbound-codec-prefs [PCMA]",
 #         time        "13:37:53.973562",
 #         type        "DEBUG"
 #     }
 # }

=head1 EXAMPLE2

=for comment filename=serialize_log_structure.pl

 use strict;
 use warnings;

 use Log::FreeSWITCH::Line qw(serialize);
 use Log::FreeSWITCH::Line::Data;

 # Data.
 my $record = Log::FreeSWITCH::Line::Data->new(
         'date' => '2014-07-01',
         'file' => 'sofia.c',
         'file_line' => 4045,
         'message' => 'inbound-codec-prefs [PCMA]',
         'time' => '13:37:53.973562',
         'type' => 'DEBUG',
 );

 # Serialize and print to stdout.
 print serialize($record)."\n";

 # Output:
 # 2014-07-01 13:37:53.973562 [DEBUG] sofia.c:4045 inbound-codec-prefs [PCMA]

=head1 DEPENDENCIES

L<Error::Pure>,
L<Exporter>,
L<Log::FreeSWITCH::Line::Data>,
L<Readonly>,
L<Scalar::Util>.

=head1 SEE ALSO

=over

=item L<Log::FreeSWITCH::Line::Data>

Data object which represents FreeSWITCH log line.

=back

=head1 REPOSITORY

L<https://github.com/michal-josef-spacek/Log-FreeSWITCH-Line>

=head1 AUTHOR

Michal Josef Špaček L<mailto:skim@cpan.org>

L<http://skim.cz>

=head1 LICENSE AND COPYRIGHT

© 2014-2022 Michal Josef Špaček

BSD 2-Clause License

=head1 VERSION

0.08

=cut



( run in 0.945 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )