UNPKG

3.86 kBJavaScriptView Raw
1// Copyright (c) 2015 Uber Technologies, Inc.
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21var TypedError = require('error/typed');
22
23// The following errors predate the transition from rt-logger to
24// logtron and for backward compatibility retain their old names.
25var OptsRequired = TypedError({
26 message: 'rt-logger: Must call Logger with opts argument.\n' +
27 'Ensure you call `Logger({ ... })`.\n',
28 type: 'rt-logger.options.required'
29});
30var MetaRequired = TypedError({
31 type: 'rt-logger.options.meta.required',
32 message: 'rt-logger: Must call Logger with "meta" key on ' +
33 'opts.\n' +
34 'Ensure you call `Logger({ meta: ... })`.\n'
35});
36var BackendsRequired = TypedError({
37 type: 'rt-logger.options.backends.required',
38 message: 'rt-logger: Must call Logger with "backends" key ' +
39 'on opts.\n' +
40 'Ensure you call `Logger({ backends: ... })`.\n'
41});
42
43// The following have been added since the transition to logtron.
44var LevelRequired = TypedError({
45 type: 'logtron.child-logger.additional-level.required',
46 message: 'logtron: Child Logger in strict mode must configure at least one ' +
47 'backend to store log level {level} produced by child logger.\n'
48});
49var UniquePathRequired = TypedError({
50 type: 'logtron.child-logger.unique-path.required',
51 message: 'logtron: Child logger must be constructed with ' +
52 'a unique path\n. {path} has already been used.\n'
53});
54var LevelDisabled = TypedError({
55 type: 'logtron.child-logger.additional-level.disabled',
56 message: 'logtron: Child Logger could not enable level' +
57 'because backend for {level} does not exist in parent.\n'
58});
59var FilterObjectRequired = TypedError({
60 type: 'logtron.child-logger.meta-filter.missing-object',
61 message: 'logtron: Child Logger requires an object key' +
62 'containing an object in each filter.\n'
63});
64var FilterMappingsRequired = TypedError({
65 type: 'logtron.child-logger.meta-filter.missing-mappings',
66 message: 'logtron: Child Logger requires at least one mapping for' +
67 'each filtered object.\n'
68});
69var FilterBadDst = TypedError({
70 type: 'logtron.child-logger.meta-filter.bad-definition',
71 message: 'logtron: Format for filters mappings is ' +
72 'an object. Each key is the location in the target object to ' +
73 'fetch the value from; each value is a string which is the ' +
74 'the target destination on the meta object.\n'
75});
76
77module.exports = {
78 OptsRequired: OptsRequired,
79 MetaRequired: MetaRequired,
80 BackendsRequired: BackendsRequired,
81 LevelRequired: LevelRequired,
82 UniquePathRequired: UniquePathRequired,
83 LevelDisabled: LevelDisabled,
84 FilterObjectRequired: FilterObjectRequired,
85 FilterMappingsRequired: FilterMappingsRequired,
86 FilterBadDst: FilterBadDst
87};