File: Options.pm

package info (click to toggle)
cricket 1.0.5-23
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,940 kB
  • sloc: perl: 8,276; ansic: 329; sh: 162; makefile: 60; sql: 16
file content (55 lines) | stat: -rw-r--r-- 1,877 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- perl -*-

# Cricket: a configuration, polling and data display wrapper for RRD files
#
#    Copyright (C) 1998 Jeff R. Allen and WebTV Networks, Inc.
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

package Common::Options;

use Getopt::Long;
use Common::Log;

sub commonOptions {
    # default to 'info' unless there's a environment variable
    # or a commandline arg
    my($logLevel, $logFormat, $base);
    $logLevel = $Common::global::gLogLevel if $Common::global::gLogLevel;
    $logLevel = $ENV{'CRICKET_LOG_LEVEL'} if $ENV{'CRICKET_LOG_LEVEL'};
    $logLevel ||= "info";

    # default to 'standard' unless there's a environment variable
    $logFormat = $Common::global::gLogFormat if $Common::global::gLogFormat;
    $logFormat = $ENV{'CRICKET_LOG_FORMAT'} if $ENV{'CRICKET_LOG_FORMAT'};
    $logFormat ||= "standard";

    GetOptions( "loglevel:s" => \$logLevel,
                "logformat:s" => \$logFormat,
                "base:s" => \$base, @_);

    $Common::global::gConfigRoot = $base if $base;
    Common::Log::setLevel($logLevel);
    Common::Log::setFormat($logFormat);
}

1;

# Local Variables:
# mode: perl
# indent-tabs-mode: nil
# tab-width: 4
# perl-indent-level: 4
# End: