Giter Site home page Giter Site logo

notice's Introduction

notice - dead simple user logging utility

license

Released under the BSD License (see LICENSE file).

overview

notice provides the command-line user of Unix-like systems with a simple logging utility of thoughts and command output. It is meant to be dead simple: just a short command-line script with a bare logging format. notice is virtually featureless so that it can be extended easily using command-line utilities.

Just type at the command line:

notice log this somewhere...

and get, in your notice log file (safely tucked away at $NOTICE_LOG):

Tue Aug 18 13:49:37 EDT 2009 -- log this somewhere...

The default location for the notice log is ~/.notice.

installation

Put the enclosed notice script somewhere in your $PATH.

notice is a stand-alone script, with dependencies on:

  • GNU bash, though sh might work, too. (Just change #!/bin/bash to #!/bin/sh.)
  • cat command (likely /bin/cat)
  • date command (likely /bin/date)

These dependencies are given on any Unix-like system, as they are part of the Unix standard.

configuration

notice evaluates the following environment variables:

  • $NOTICE_DATE -- text to use for timestamp of notice. (default: get output of date) note that this is static text when provided, so repeated calls to notice will use the same text given in $NOTICE_DATE.
  • $NOTICE_DATE_FORMAT -- format to use for date output. see man date (default: default of date). not used if $NOTICE_DATE is set.
  • $NOTICE_SEP -- separator between date and content (default: --).
  • $NOTICE_LOG -- path of notice log file (default: $HOME/.notice).
  • $HOME -- if $NOTICE_LOG is not given, notice will evaluate the location given by $HOME/.notice.

See the section titled "example" for a type script of examples on how to use these configuration variables.

format

The basic format of the notice log is, when args are given:

${NOTICE_DATE}${NOTICE_SEP}${args}

The basic format of the notice log is, when reading from stdin:

${NOTICE_DATE}${NOTICE_SEP}${stdin}${NOTICE_SEP}

With notice defaults, a call of notice Hello, world! will look like:

Sat Aug 15 19:15:39 EDT 2009 -- Hello, world!

where the date would match the output of date on the local system. (See defaults in section titled "configuration.")

how simple?

The first cut of notice was a single line of bash:

echo ${NOW:-`date`}${DELIMITER:-" -- "}${@}>>${NOTICE_LOG:-"$HOME/.notice"}

example

Here is an example of using notice in a bash session (cwd: $HOME):

$ notice Hello, world!
$ notice follow shell semantics or it won't work
> '
$ notice follow shell semantics or it won\'t work
$ notice this example is in bash
$ date && cat .notice
Sat Aug 15 20:04:16 EDT 2009
Sat Aug 15 20:03:36 EDT 2009 -- Hello, world!
Sat Aug 15 20:03:58 EDT 2009 -- follow shell semantics or it wont work

Sat Aug 15 20:04:04 EDT 2009 -- follow shell semantics or it won't work
Sat Aug 15 20:04:10 EDT 2009 -- this example is in bash
$ notice
This is read from stdin.
We no longer have to worry about the shell, but we do have to worry about
editing stdin (we can't, really).
(Hit ctrl-D to provide EOF and close stdin.)
$ cat .notice
Sat Aug 15 20:03:36 EDT 2009 -- Hello, world!
Sat Aug 15 20:03:58 EDT 2009 -- follow shell semantics or it wont work

Sat Aug 15 20:04:04 EDT 2009 -- follow shell semantics or it won't work
Sat Aug 15 20:04:10 EDT 2009 -- this example is in bash
Sat Aug 15 20:04:32 EDT 2009 --
This is read from stdin.
We no longer have to worry about the shell, but we do have to worry about
editing stdin (we can't, really).
(Hit ctrl-D to provide EOF and close stdin.)
 --
$
$ export NOTICE_DATE= NOTICE_SEP=
$ notice lines no longer have a date or separator
$ tail -1 .notice
lines no longer have a date or separator
$ export NOTICE_DATE=log NOTICE_SEP=': '
$ notice lines now start with 'log: '
$ tail -1 .notice 
log: lines now start with log: 
$ 
$ unset NOTICE_DATE NOTICE_SEP 
$ export NOTICE_LOG=log
$ notice notice now inserts content into file at 'log'
$ cat log 
Sat Aug 15 20:09:26 EDT 2009 -- notice now inserts content into file at log
$ notice go forth and log abundantly
$ cat log 
Sat Aug 15 20:09:26 EDT 2009 -- notice now inserts content into file at log
Sat Aug 15 20:09:48 EDT 2009 -- go forth and log abundantly
$ 
$ notice pipe into notice to log command output
$ date | notice
$ tail -4 log
Sat Aug 15 20:14:16 EDT 2009 -- pipe into notice to log command output
Sat Aug 15 20:14:22 EDT 2009 -- 
Sat Aug 15 20:14:22 EDT 2009
 -- 
$ 

notice's People

Contributors

rduplain avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

dirkakrid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.