How to interprit git create mode message

 file permissions - How to read the mode field of git-ls-tree's output - Stack Overflow


From the Git index-format.txt file, regarding the mode:

32-bit mode, split into (high to low bits)

    4-bit object type
      valid values in binary are 1000 (regular file), 1010 (symbolic link)
      and 1110 (gitlink)

    3-bit unused

    9-bit unix permission. Only 0755 and 0644 are valid for regular files.
    Symbolic links and gitlinks have value 0 in this field.

Also, a directory object type (binary 0100) and group-writeable (0664 permissions) regular file are allowed as indicated by the fsck.c fsck_tree method. The regular non-executable group-writeable file is a non-standard mode that was supported in earlier versions of Git.

This makes valid modes (as binary and octal):

  • 0100000000000000 (040000): Directory
  • 1000000110100100 (100644): Regular non-executable file
  • 1000000110110100 (100664): Regular non-executable group-writeable file
  • 1000000111101101 (100755): Regular executable file
  • 1010000000000000 (120000): Symbolic link
  • 1110000000000000 (160000): Gitlink

The 6 digits show the file mode using the classical UNIX notations. First two digits show file type, the third one is about set-uid/set-gid/sticky bits, and you know the last three.

Here is how man 2 stat documents it on my GNU/Linux system:

   The following flags are defined for the st_mode field:

       S_IFMT     0170000   bit mask for the file type bit fields
       S_IFSOCK   0140000   socket
       S_IFLNK    0120000   symbolic link
       S_IFREG    0100000   regular file
       S_IFBLK    0060000   block device
       S_IFDIR    0040000   directory
       S_IFCHR    0020000   character device
       S_IFIFO    0010000   FIFO
       S_ISUID    0004000   set UID bit
       S_ISGID    0002000   set-group-ID bit (see below)
       S_ISVTX    0001000   sticky bit (see below)
       S_IRWXU    00700     mask for file owner permissions
       S_IRUSR    00400     owner has read permission
       S_IWUSR    00200     owner has write permission
       S_IXUSR    00100     owner has execute permission
       S_IRWXG    00070     mask for group permissions
       S_IRGRP    00040     group has read permission
       S_IWGRP    00020     group has write permission
       S_IXGRP    00010     group has execute permission
       S_IRWXO    00007     mask for permissions for others (not in group)
       S_IROTH    00004     others have read permission           
       S_IWOTH    00002     others have write permission
       S_IXOTH    00001     others have execute permission

New Angular, Nodejs + Express

 Angular - Create a new project

Express application generator (expressjs.com)


ng new angular-tour-of-heroes

$ npm install -g express-generator
express --view=pug myapp

Angular: How do I navigate to a sibling route?

 angular - How do I navigate to a sibling route? - Stack Overflow


Update 08/02/2019 Angular 7.1.0

current route: /department/7/employees/45/sales

the old version will do: /department/7/employees/45/sales/contacts

As per @KCarnaille's comment the above does not work with the latest Router. The new way is to add .parent to this.r so

    // Working(08/02/2019) 
    goToContact() {
       this.router.navigate(["../contacts"], { relativeTo: this.r.parent });
    }

the update will do: /department/7/employees/45/contacts

Winston Log: Restrict transport to only 1 level

 Target specific only specific log levels · Issue #1108 · winstonjs/winston (github.com)

winstonjs/winston: A logger for just about everything. (github.com)

This kind of feature request is exactly why format was introduced in winston@3. You can define a format for this for each of the transports:

const { createLogger, format } = require('winston');
const LEVEL = Symbol.for('level');

/**
 * Log only the messages the match `level`.
 */
function filterOnly(level) {
  return format(function (info) {
    if (info[LEVEL] === level) {
      return info;
    }
  })();
}

const logger = createLogger({
  format: zformat,
  transports: [
    // only 'info' level
    new transprts.File({
      level: 'info',
      format: filterOnly('info'),
      filename: 'logs/access.log',
    }),
    // any level below 'verbose'
    new transports.File({
      level: 'verbose',
      format: filterOnly('verbose'),
      filename: 'logs/combined.log',
    })
  ]
});

Filtering info Objects

If you wish to filter out a given info Object completely when logging then simply return a falsey value.

const { createLogger, format, transports } = require('winston');

// Ignore log messages if they have { private: true }
const ignorePrivate = format((info, opts) => {
  if (info.private) { return false; }
  return info;
});

const logger = createLogger({
  format: format.combine(
    ignorePrivate(),
    format.json()
  ),
  transports: [new transports.Console()]
});

// Outputs: {"level":"error","message":"Public error to share"}
logger.log({
  level: 'error',
  message: 'Public error to share'
});

// Messages with { private: true } will not be written when logged.
logger.log({
  private: true,
  level: 'error',
  message: 'This is super secret - hide it.'
});

Use of format.combine will respect any falsey values return and stop evaluation of later formats in the series. For example:

const { format } = require('winston');
const { combine, timestamp, label } = format;

const willNeverThrow = format.combine(
  format(info => { return false })(), // Ignores everything
  format(info => { throw new Error('Never reached') })()
);
const { createLoggerformattransports } = require('winston');
const LEVEL = Symbol.for('level');

/**
 * Log only the messages the match `level`.
 */
 function filterOnly(level) {
  return format(function (info) {
    if (info[LEVEL] === level) {
      return info;
    }
  })();
}

const logger = createLogger({
  level: 'info',
  format: format.json(),
  defaultMeta: { service: 'user-service' },
  transports: [
    //
    // - Write all logs with level `error` and below to `error.log`
    // - Write all logs with level `info` and below to `combined.log`
    //
    new transports.File({ filename: 'logs/error.log'level: 'error' }),
    new transports.Console({ 
      level: 'debug',
      format: format.combine(
        format.colorize(),
        filterOnly('debug')
      )
     }),
  ],
});


// const levels = {
//   error: 0,
//   warn: 1,
//   info: 2,
//   verbose: 3,
//   debug: 4,
//   silly: 5
// };

logger.log('error'"127.0.0.1 - there's no place like home");

logger.log('warn'"127.0.0.1 - there's no place like home");

logger.log('info'"127.0.0.1 - there's no place like home");

logger.log('verbose'"127.0.0.1 - there's no place like home");

logger.log('debug'"127.0.0.1 - there's no place like home");

logger.log('silly'"127.0.0.1 - there's no place like home");


 What is MORGAN in Node.js ? - GeeksforGeeks

Add Server Logs to your Node.js App with Morgan and Winston | heynode.com

Express morgan middleware (expressjs.com)

Node.js - logging / Use morgan and winston - Stack Overflow

Advanced logging with NodeJs | Ugo Lattanzi's tech world (tostring.it)

Morgan is an HTTP request level Middleware. It is a great tool that logs the requests along with some other information depending upon its configuration and the preset used. It proves to be very helpful while debugging and also if you want to create Log files.


Now that we have our logger installed, we'll need a way to use it. In our App.js file we’re going to bring in Morgan for capturing HTTP requests. We'll use Morgan’s standard "combined" format and pass the stream to our Winston logger.

const express = require('express');
const app = express();
const morgan = require('morgan');
const logger = require('./config/winston');
const port = 8080
app.use(morgan("combined", { stream: logger.stream.write }));
app.get('/', function(req, res) {
    throw new Error('error thrown navigating to');
});
app.use(function(err, req, res, next) {
  logger.error(`${req.method} - ${err.message}  - ${req.originalUrl} - ${req.ip}`);
  next(err)
})  
app.listen(port, console.log(`Listening on port ${port}!`));


This article does an excellent job for what you want to do.

http://tostring.it/2014/06/23/advanced-logging-with-nodejs/

For your specific code you probably need something like this:

var logger = new winston.Logger({
    transports: [
        new winston.transports.File({
            level: 'info',
            filename: './logs/all-logs.log',
            handleExceptions: true,
            json: true,
            maxsize: 5242880, //5MB
            maxFiles: 5,
            colorize: false
        }),
        new winston.transports.Console({
            level: 'debug',
            handleExceptions: true,
            json: false,
            colorize: true
        })
    ],
    exitOnError: false
});

logger.stream = {
    write: function(message, encoding){
        logger.info(message);
    }
};

app.use(require("morgan")("combined", { "stream": logger.stream }));

This will set up Winston to write a log to the console as well as a file. Then you can use the last expression to pass output from the morgan middleware into winston.

write logs to a file

single file

Sample app that will log all requests in the Apache combined format to the file access.log.

var express = require('express')
var fs = require('fs')
var morgan = require('morgan')
var path = require('path')

var app = express()

// create a write stream (in append mode)
var accessLogStream = fs.createWriteStream(path.join(__dirname, 'access.log'), { flags: 'a' })

// setup the logger
app.use(morgan('combined', { stream: accessLogStream }))

app.get('/', function (req, res) {
  res.send('hello, world!')
})

log file rotation

Sample app that will log all requests in the Apache combined format to one log file per day in the log/ directory using the rotating-file-stream module.

var express = require('express')
var morgan = require('morgan')
var path = require('path')
var rfs = require('rotating-file-stream') // version 2.x

var app = express()

// create a rotating write stream
var accessLogStream = rfs.createStream('access.log', {
  interval: '1d', // rotate daily
  path: path.join(__dirname, 'log')
})

// setup the logger
app.use(morgan('combined', { stream: accessLogStream }))

app.get('/', function (req, res) {
  res.send('hello, world!')
})

Cold Turkey Blocker

 https://superuser.com/questions/1366153/how-to-get-rid-of-cold-turkey-website-blocker-get-around-the-block Very old question, but still wan...