View | Details | Raw Unified | Return to bug 13799
Collapse All | Expand All

(-)a/Koha/REST/V1.pm (-1 / +35 lines)
Lines 2-11 package Koha::REST::V1; Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use Mojo::Base 'Mojolicious';
4
use Mojo::Base 'Mojolicious';
5
use Mojo::Log;
6
7
=head startup
8
9
Starts the Mojolicious application using whatever server is configured.
10
11
Use environmental values to control some aspects of Mojolicious:
12
This way we can have different settings for different servers running Mojolicious.
13
14
=head2 Configuration file
15
16
$ENV{MOJO_CONFIG} should be set in the system service (init) starting Mojolicious, eg:
17
export MOJO_CONFIG=/home/koha/kohaclone/api/v1/hypnotoad.conf
18
19
This configuration file read by the Mojolicious::Plugin::Config
20
http://mojolicio.us/perldoc/Mojolicious/Plugin/Config
21
22
=head2 Logging
23
24
Log to a filename configured in an environemnt variable $ENV{MOJO_LOGFILE} using loglevel $ENV{MOJO_LOGLEVEL}.
25
Defaults to '/tmp/koha-api.log' and loglevel of 'error'
26
Examples:
27
export MOJO_LOGFILE=/home/koha/koha-dev/var/log/kohaapi.mojo.log
28
export MOJO_LOGLEVEL=debug
29
30
Logging is done by Mojo::Log
31
http://www.mojolicio.us/perldoc/Mojo/Log
32
33
=cut
5
34
6
sub startup {
35
sub startup {
7
    my $self = shift;
36
    my $self = shift;
8
37
38
    #Log to a filename with loglevel configured in environment variables
39
    $self->app->log( Mojo::Log->new( path => ($ENV{MOJO_LOGFILE} || "/tmp/koha-api.log"), level => ($ENV{MOJO_LOGLEVEL} || 'error') ) );
40
41
    #Enable the config-plugin. Loads the config file from $ENV{MOJO_CONFIG} by default.
42
    $self->plugin('Config');
43
9
    my $route = $self->routes->under->to(
44
    my $route = $self->routes->under->to(
10
        cb => sub {
45
        cb => sub {
11
            my $c = shift;
46
            my $c = shift;
12
- 

Return to bug 13799