1###
2# Copyright (c) 2005, Jeremiah Fincher
3# Copyright (c) 2009, James McCoy
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are met:
8#
9#   * Redistributions of source code must retain the above copyright notice,
10#     this list of conditions, and the following disclaimer.
11#   * Redistributions in binary form must reproduce the above copyright notice,
12#     this list of conditions, and the following disclaimer in the
13#     documentation and/or other materials provided with the distribution.
14#   * Neither the name of the author of this software nor the name of
15#     contributors to this software may be used to endorse or promote products
16#     derived from this software without specific prior written consent.
17#
18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28# POSSIBILITY OF SUCH DAMAGE.
29###
30
31import supybot.conf as conf
32import supybot.registry as registry
33from supybot.i18n import PluginInternationalization, internationalizeDocstring
34_ = PluginInternationalization('ChannelLogger')
35
36def configure(advanced):
37    # This will be called by supybot to configure this module.  advanced is
38    # a bool that specifies whether the user identified themself as an advanced
39    # user or not.  You should effect your configuration by manipulating the
40    # registry as appropriate.
41    from supybot.questions import expect, anything, something, yn
42    conf.registerPlugin('ChannelLogger', True)
43
44ChannelLogger = conf.registerPlugin('ChannelLogger')
45conf.registerChannelValue(ChannelLogger, 'enable',
46    registry.Boolean(True, _("""Determines whether logging is enabled.""")))
47conf.registerGlobalValue(ChannelLogger, 'flushImmediately',
48    registry.Boolean(True, _("""Determines whether channel logfiles will be
49    flushed anytime they're written to, rather than being buffered by the
50    operating system.""")))
51conf.registerChannelValue(ChannelLogger, 'showJoinParts',
52    registry.Boolean(True, _("""Determines wether joins and parts are logged""")))
53conf.registerChannelValue(ChannelLogger, 'stripFormatting',
54    registry.Boolean(True, _("""Determines whether formatting characters (such
55    as bolding, color, etc.) are removed when writing the logs to disk.""")))
56conf.registerChannelValue(ChannelLogger, 'timestamp',
57    registry.Boolean(True, _("""Determines whether the logs for this channel are
58    timestamped with the timestamp in supybot.log.timestampFormat.""")))
59conf.registerChannelValue(ChannelLogger, 'noLogPrefix',
60    registry.String('[nolog]', _("""Determines what string a message should be
61    prefixed with in order not to be logged.  If you don't want any such
62    prefix, just set it to the empty string.""")))
63conf.registerChannelValue(ChannelLogger, 'rotateLogs',
64    registry.Boolean(False, _("""Determines whether the bot will automatically
65    rotate the logs for this channel.  The bot will rotate logs when the
66    timestamp for the log changes.  The timestamp is set according to
67    the 'filenameTimestamp' configuration variable.""")))
68conf.registerChannelValue(ChannelLogger, 'filenameTimestamp',
69    registry.String('%Y-%m-%d', _("""Determines how to represent the timestamp
70    used for the filename in rotated logs.  When this timestamp changes, the
71    old logfiles will be closed and a new one started. The format characters
72    for the timestamp are in the time.strftime docs at python.org.  In order
73    for your logs to be rotated, you'll also have to enable
74    supybot.plugins.ChannelLogger.rotateLogs.""")))
75
76conf.registerGlobalValue(ChannelLogger, 'directories',
77    registry.Boolean(True, _("""Determines whether the bot will partition its
78    channel logs into separate directories based on different criteria.""")))
79conf.registerGlobalValue(ChannelLogger.directories, 'network',
80    registry.Boolean(True, _("""Determines whether the bot will use a network
81    directory if using directories.""")))
82conf.registerGlobalValue(ChannelLogger.directories, 'channel',
83    registry.Boolean(True, _("""Determines whether the bot will use a channel
84    directory if using directories.""")))
85conf.registerGlobalValue(ChannelLogger.directories, 'timestamp',
86    registry.Boolean(False, _("""Determines whether the bot will use a timestamp
87    (determined by supybot.plugins.ChannelLogger.directories.timestamp.format)
88    if using directories.""")))
89conf.registerGlobalValue(ChannelLogger.directories.timestamp, 'format',
90    registry.String('%B', _("""Determines what timestamp format will be used in
91    the directory structure for channel logs if
92    supybot.plugins.ChannelLogger.directories.timestamp is True.""")))
93
94# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
95