Config

Fontlib can be configured with a configuration file (see basic config and logging setup) and/or with command line arguments (see fontlib options). If nothing is given, the application defaults and logging defaults come to the effect.

basic config and logging setup

To install templates for indiviual configuration use the config install command:

$ fontlib config install ~/.fontlib
using workspace: ~/.fontlib
set log level of logger: fontlib (WARNING)
log goes to:
 - <StreamHandler <stderr> (DEBUG)>
install:  ~/.fontlib/config.ini
install:  ~/.fontlib/log.ini

This will setup a workspace folder .fontlib in your home folder where templates for application defaults and logging defaults are copied in. To activate the configuration in .fontlib/log.ini just un-comment the config line:

[logging]
...
config = %(workspace)s/log.ini

inspect configuration

With command fontlib config show you can inspect current configuration options. To show your current configuration use fontlib config show. With switch --verbose you will get some more information.:

$ fontlib --verbose config show
using workspace: ~/.fontlib
set log level of logger: fontlib (WARNING)
log goes to:
- <StreamHandler <stderr> (DEBUG)>

config.ini
==========

[DEFAULT]
workspace = ~/.fontlib

[fontstack]
builtin fonts = cantarell, dejavu
entry points = fonts_ttf, fonts_otf, fonts_woff, fonts_woff2
cache = fontlib.urlcache.SimpleURLCache
...

log.ini
=======

[loggers]
keys = root, fontlib
...

application defaults

The default application configuration is taken from the git://fontlib/config.ini file:

 1# -*- coding: utf-8; mode: ini -*-
 2
 3[DEFAULT]
 4
 5workspace = ~/.fontlib
 6
 7# persistence of fontlib's applications
 8# https://docs.sqlalchemy.org/engines.html#database-urls
 9fontlib_db = sqlite:////%(workspace)s/fontlib.db
10# fontlib_db = sqlite:///:memory:
11
12[fontstack]
13
14# Fonts loaded from builtins.
15builtin fonts = cantarell, dejavu
16
17# Fonts loaded from entry points.
18entry points = fonts_ttf, fonts_otf, fonts_woff, fonts_woff2
19
20# Full qualified name of the URL-cache implementation.  Subclass of
21# fontlib.urlcache.URLCache.  e.g.: fontlib.urlcache.SimpleURLCache
22# or fontlib.urlcache.NoCache
23cache = fontlib.urlcache.SimpleURLCache
24
25[google fonts]
26
27# Select font families from https://fonts.google.com/
28family base url = https://fonts.googleapis.com/css?family=
29
30# https://github.com/googlefonts/robotoslab
31# https://github.com/googlefonts/staatliches
32# https://github.com/graphicore/librebarcode
33fonts = Roboto Slab, Staatliches, Libre Barcode 39 Extended Text, Leckerli One
34
35[logging]
36
37# Threshold for the logger
38# Value: debug | info | warning | error | critical
39level = warning
40
41# activate this line to use the logger configuration from your workspace
42# config = %(workspace)s/log.ini

logging defaults

Fontlib uses the standard py-logging facility. The default logging configuration is taken from the git://fontlib/log.ini file (shown below). For details options see py-logging INI format.

 1# -*- coding: utf-8; mode: ini -*-
 2#
 3# fontlib logging configuration
 4#
 5# https://docs.python.org/3/library/logging.config.html#configuration-file-format
 6#
 7
 8[loggers]
 9keys = root, fontlib, sqlalchemy_engine
10
11[logger_root]
12level = NOTSET
13handlers = null
14
15[logger_fontlib]
16level = WARNING
17#handlers = console, logfile
18handlers = console
19# The qualname entry is the hierarchical channel name of the logger, that is to
20# say the name used by the application to get the logger.
21qualname = fontlib
22propagate = 1
23
24[logger_sqlalchemy_engine]
25level = WARNING
26#handlers = console, logfile
27handlers = console
28qualname = sqlalchemy.engine
29propagate = 1
30
31[handlers]
32keys = null, console, logfile
33
34[handler_null]
35class = NullHandler
36level = NOTSET
37args = ()
38
39[handler_console]
40class = StreamHandler
41level = DEBUG
42formatter = console
43# https://docs.python.org/3.7/library/logging.handlers.html#logging.StreamHandler
44args = (sys.stderr, )
45
46[handler_logfile]
47class = handlers.RotatingFileHandler
48level = DEBUG
49formatter = logfile
50# https://docs.python.org/3.7/library/logging.handlers.html#logging.handlers.RotatingFileHandler
51args = ('%(WORKSPACE)s/%(APP)s.log', )
52kwargs = {'maxBytes' : 1024 * 1024, 'backupCount' : 10 }
53
54[formatters]
55keys = console, logfile
56
57[formatter_console]
58format = ~~ LOG.%(levelname)s [%(name)-12s] %(message)s
59
60[formatter_logfile]
61format = %(asctime)s| %(levelname)-8s|%(name)-12s| %(message)s

Source Code Remarks

Implementation of application’s configuration class Config.