3 UCI Validation Layer - Logging utilities
4 (c) 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
5 (c) 2008 Steven Barth <steven@midlink.org>
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
17 module( "luci.uvl.loghelper", package.seeall )
19 function config_error( config, message )
21 'Error in config "%s":\n%s',
22 config, message or "Unknown error"
26 function section_error( section, message )
28 'Error in section "%s":\n%s',
29 section:cid(), message or "Unknown error"
33 function validator_error( option, message )
35 'External validator in option "%s" failed:\n%s',
36 option:cid(), message or "Unknown error"
40 function scheme_error( scheme, message )
42 'Error while loading scheme "%s":\n%s',
43 scheme, message:gsub("^.-:.-: ","")
47 function dump_dependency( dep, ref, v, e )
50 for k, v in luci.util.spairs( dep,
52 a = ( type(dep[a]) ~= "boolean" and "_" or "" ) .. a
53 b = ( type(dep[b]) ~= "boolean" and "_" or "" ) .. b
57 str = ( str and str .. " and " or "Dependency (" ) .. k ..
58 ( type(v) ~= "boolean" and "=" .. v or "" )
63 str, e and e:gsub("\n","\n\t") or string.format(
65 table.concat( ref, "." ), (
67 and "has no value" or 'is not equal "' .. v .. '"'
75 function id( c, s, o )
76 if type(c) == "table" then
80 return c .. ( s and '.' .. s or '' ) .. ( o and '.' .. o or '' )