# secretary

> Bring common sense to console logging.

Latest version **0.1.0** (published 2013-01-30) · 0 weekly downloads

## Install

```sh
npm install secretary
pnpm add secretary
yarn add secretary
bun add secretary
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2013-01-30 |
| First published | 2012-12-24 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Kyle Hughes |
| Maintainers | kylehughes |
| Keywords | console, color, output, format, text, shell, xterm |

## Links

- npm: https://www.npmjs.com/package/secretary
- Repository: https://github.com/kylehughes/secretary
- npm.io page: https://npm.io/package/secretary

## Dependencies (1)

- [cli-color](https://npm.io/package/cli-color.md) 0.2.1

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2013-01-30
- 0.0.4 — 2013-01-29
- 0.0.3 — 2013-01-02
- 0.0.2 — 2013-01-02
- 0.0.1 — 2012-12-24

## README

#secretary#

A *node.js* module that brings common sense to console logging.

##Installation##

    npm install secretary

##Setup##

####Configuration:####
```javascript
sec.configure({
    minFlag: 1,
    maxFlag: 5,
    minRunningFlag: 3,
    maxRunningFlag: 4
});
```

The potential configuration options are as follows:
- __minFlag__ - *default: 1* - The lowest possible flag for any output. This must be >= 1.
- __maxFlag__ - *default: 10* - The highest possible flag for any output. This must be >= 1.
- __minRunningFlag__ - *default: minFlag* - The lowest flag whose output will be processed when the program is run.
This value must fall within the range of the *minFlag* and the *maxFlag* or it will not be registered.
- __maxRunningFlag__ - *default: maxFlag* - The highest flag whose output will be processed when the program is run.
This value must fall within the range of the *minFlag* and the *maxFlag* or it will not be registered.

##Usage##

####Instantiation:####
```javascript
var sec = require('secretary');
```

####Filtering:####

One of the key features of *secretary* is the ability to ~~litter your code with~~ thoughtfully place console logging throughout your code,
and have it filtered out at runtime by the flag that was supplied with the output. This way, you're always in control of the verbosity of your output,
during development and during production. It also does away with the need for quick-and-dirty *console.log*s that you delete shortly afterwards.

We implement flags by chaining `flag()` in front of any log call, and passing it the flag level we want to set.

If we assume the following configuration:
```javascript
minFlag: 1,
maxFlag: 5,
minRunningFlag: 3
```

And then run the following code:
```javascript
sec.flag(1).log('Beginning DEBUG output...');
sec.flag(3).log('Integrity check successful');
sec.flag(5).log('Server starting on port 3000');
```

We will see the following output:
```
Integrity check successful
Server starting on port 3000
```

By it's nature, `flag()` sets what the flag level is for the next `log()` call. Thus, the following is valid usage:
```javascript
sec.flag(4);
sec.log('Starting thermonuclear war...'); // Evaluated with flag level 4
```

It is also possible to use `log()` without any chain to `flag()` which results in the minimum running flag to be applied to the log, meaning it will always be displayed no matter what.

####Formatting Data:####

Much like `console.log()`, *secretary* supports the formatting of data. `log()` can take multiple arguments in a `printf()` sort of way.

The first argument passed to `log()` is always assumed and expected to be the desired output string. If other arguments are included, they are all assumed to be data that need to be formatted into the string. String formatting is done by the `util.format()` method, so all rules that apply there apply here.

The basic supported placeholders are listed below:
>
- %s : String
- %d : Number (both integer and float)
- %j : JSON
- % : single percent sign ('%'); this does not consume an argument

For the entire range of `util.format()` rules, see [here](http://nodejs.org/api/util.html#util_util_format_format).

Examples of this in use:

```javascript
sec.flag(3).log('%s, %s.', 'Hello', 'Mister');
// 'Hello, Mister.'
```
```javascript
sec.log('%d:%d', 12);
// '12:%d'
```
```javascript
sec.flag(1).log('Hello', '1', '2', 3);
// 'Hello 1 2 3'
```

---
_Source: https://npm.io/package/secretary · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
