当前位置: 首页>>代码示例>>Golang>>正文


Golang xlog.New函数代码示例

本文整理汇总了Golang中github.com/hlandau/xlog.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ByDirectoryURL

package acmeendpoints

import (
	"bytes"
	"crypto/sha256"
	"crypto/x509"
	"errors"
	"fmt"
	"github.com/hlandau/acme/acmeapi"
	"github.com/hlandau/xlog"
	"golang.org/x/net/context"
	"net/url"
	"regexp"
)

var log, Log = xlog.New("acme.endpoints")

// Returned when no matching endpoint can be found.
var ErrNotFound = errors.New("no corresponding endpoint found")

// Finds an endpoint with the given directory URL. If no such endpoint is
// found, returns ErrNotFound.
func ByDirectoryURL(directoryURL string) (*Endpoint, error) {
	for _, e := range endpoints {
		if directoryURL == e.DirectoryURL {
			return e, nil
		}
	}

	return nil, ErrNotFound
}
开发者ID:joneskoo,项目名称:acmetool-kapsi,代码行数:31,代码来源:url.go

示例2:

import "github.com/willf/bloom"

//import "github.com/hlandau/degoutils/dbutil"
import "text/template"
import htmltemplate "html/template"
import "time"

//import "github.com/hlandau/degoutils/sendemail"
import "crypto/sha256"

//import "github.com/jackc/pgx"

import "database/sql"
import "github.com/lib/pq"

var log, Log = xlog.New("ctmon.server")

type Config struct {
	DBURI string `default:"" usage:"PostgreSQL DB URI"`
}

type Server struct {
	cfg         Config
	stopping    int32
	stopWait    sync.WaitGroup
	stopChan    chan struct{}
	stopOnce    sync.Once
	bloomFilter *bloom.BloomFilter
	//dbpool             *pgx.ConnPool
	dbpool             *sql.DB
	textNotifyEmailTpl *template.Template
开发者ID:hlandau,项目名称:ctmon,代码行数:31,代码来源:server.go

示例3:

// Package fdb allows for the use of a filesystem directory as a simple
// database on UNIX-like systems.
package fdb

import (
	"fmt"
	"github.com/hlandau/xlog"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
)

var log, Log = xlog.New("fdb")

// FDB instance.
type DB struct {
	cfg        Config
	path       string
	extantDirs map[string]struct{}
}

// FDB configuration.
type Config struct {
	Path        string
	Permissions []Permission
}

// Expresses the permission policy for a given path. The first match is used.
type Permission struct {
	// The path to which the permission applies. May contain wildcards and must
开发者ID:madalinignisca,项目名称:acme,代码行数:31,代码来源:fdb.go

示例4:

	"github.com/hlandau/acme/hooks"
	"github.com/hlandau/acme/interaction"
	"github.com/hlandau/acme/redirector"
	"github.com/hlandau/acme/responder"
	"github.com/hlandau/acme/storage"
	"github.com/hlandau/acme/storageops"
	"github.com/hlandau/dexlogconfig"
	"github.com/hlandau/xlog"
	"gopkg.in/alecthomas/kingpin.v2"
	"gopkg.in/hlandau/easyconfig.v1/adaptflag"
	"gopkg.in/hlandau/service.v2"
	"gopkg.in/square/go-jose.v1"
	"gopkg.in/yaml.v2"
)

var log, Log = xlog.New("acmetool")

var (
	stateFlag = kingpin.Flag("state", "Path to the state directory (env: ACME_STATE_DIR)").
			Default(storage.RecommendedPath).
			Envar("ACME_STATE_DIR").
			PlaceHolder(storage.RecommendedPath).
			String()

	hooksFlag = kingpin.Flag("hooks", "Path to the notification hooks directory (env: ACME_HOOKS_DIR)").
			Default(hooks.RecommendedPath).
			Envar("ACME_HOOKS_DIR").
			PlaceHolder(hooks.RecommendedPath).
			String()

	batchFlag = kingpin.Flag("batch", "Do not attempt interaction; useful for cron jobs. (acmetool can still obtain responses from a response file, if one was provided.)").
开发者ID:hlandau,项目名称:acme,代码行数:31,代码来源:main.go

示例5:

	"errors"
	"fmt"
	deos "github.com/hlandau/goutils/os"
	"github.com/hlandau/xlog"
	"gopkg.in/hlandau/svcutils.v1/chroot"
	"gopkg.in/hlandau/svcutils.v1/passwd"
	"gopkg.in/tylerb/graceful.v1"
	"html"
	"net"
	"net/http"
	"os"
	"sync/atomic"
	"time"
)

var log, Log = xlog.New("acme.redirector")

// Configuration for redirector.
type Config struct {
	Bind          string `default:":80" usage:"Bind address"`
	ChallengePath string `default:"" usage:"Path containing HTTP challenge files"`
	ChallengeGID  string `default:"" usage:"GID to chgrp the challenge path to (optional)"`
}

// Simple HTTP to HTTPS redirector.
type Redirector struct {
	cfg          Config
	httpServer   graceful.Server
	httpListener net.Listener
	stopping     uint32
}
开发者ID:hlandau,项目名称:acme,代码行数:31,代码来源:redirector.go

示例6: GetTemplate

// Package tpl provides facilities for loading and displaying templates.
package tpl

import "path/filepath"
import "github.com/flosch/pongo2"
import "fmt"
import "github.com/hlandau/xlog"
import "net/http"
import "github.com/hlandau/degoutils/web/miscctx"
import "github.com/hlandau/degoutils/web/opts"
import "github.com/hlandau/degoutils/vfs"
import "github.com/hlandau/degoutils/binarc"
import "io"

var log, Log = xlog.New("web.tpl")

// Loaded templates.
var templates = map[string]*pongo2.Template{}

// Try to find a template with the given name. Returns nil if there is no such
// template loaded.
func GetTemplate(name string) *pongo2.Template {
	return templates[name]
}

// Load all templates from the given directory. The templates must have the file extension ".p2".
func LoadTemplates(dirname string) error {
	err := binarc.Setup(opts.BaseDir)
	if err != nil {
		return err
	}
开发者ID:hlandau,项目名称:degoutils,代码行数:31,代码来源:tpl.go

示例7:

import (
	"crypto/sha256"
	"encoding/base64"
	"encoding/binary"
	"github.com/hlandau/degoutils/vfs"
	"github.com/hlandau/xlog"
	"github.com/rjeczalik/notify"
	"io"
	"os"
	"path/filepath"
	"regexp"
	"sync"
	"time"
)

var log, Log = xlog.New("web.assetmgr")

var allDigits = regexp.MustCompile(`^[0-9]+$`)

// Asset manager configuration.
type Config struct {
	Path string // Path to assets.
}

// Represents a known asset file.
type file struct {
	mtime    time.Time
	tag      string
	sha256   []byte
	fullpath string
}
开发者ID:hlandau,项目名称:degoutils,代码行数:31,代码来源:assetmgr.go

示例8: makeInsertPairs

package dbutil

import (
	"fmt"
	"github.com/hlandau/xlog"
	"github.com/jackc/pgx"
	"strings"
)

var log, Log = xlog.New("dbutil")

type DBI interface {
	Exec(sql string, args ...interface{}) (pgx.CommandTag, error)
	Query(sql string, args ...interface{}) (*pgx.Rows, error)
	QueryRow(sql string, args ...interface{}) *pgx.Row
}

func makeInsertPairs(extras []string, args ...interface{}) (keystr, placeholderstr string, values []interface{}) {
	isKey := true
	var keys = make([]string, len(extras), len(args)/2+len(extras))
	var placeholders = make([]string, 0, len(args)/2+len(extras))
	values = make([]interface{}, len(extras), len(args)/2+len(extras))
	no := 1
	for i := 0; i < len(extras); i++ {
		keys[i] = extras[i]
		placeholders = append(placeholders, fmt.Sprintf("$%d", no))
		no++
	}
	for _, arg := range args {
		if isKey {
			keys = append(keys, "\""+arg.(string)+"\"")
开发者ID:hlandau,项目名称:degoutils,代码行数:31,代码来源:dbutil.go

示例9: Setup

package binarc

import "sync"
import "os"
import "gopkg.in/hlandau/svcutils.v1/exepath"
import "github.com/hlandau/degoutils/vfs"
import "github.com/hlandau/degoutils/vfs/zipfs"
import "github.com/hlandau/xlog"

var log, Log = xlog.New("binarc")

var setupOnce sync.Once
var inlineArchive vfs.Filesystem

func Setup(path string) error {
	setupOnce.Do(func() {
		f, err := openSelfFile()
		if err != nil {
			log.Errore(err, "cannot open self")
			return
		}

		finfo, err := f.Stat()
		if err != nil {
			f.Close()
			log.Errore(err, "cannot stat self")
			return
		}

		arc, err := zipfs.New(f, finfo.Size())
		if err != nil {
开发者ID:hlandau,项目名称:degoutils,代码行数:31,代码来源:binarc.go

示例10:

package responder

import (
	"crypto"
	"crypto/sha256"
	"encoding/base64"
	"encoding/hex"
	"encoding/json"
	"fmt"
	"github.com/hlandau/acme/interaction"
	"github.com/hlandau/xlog"
	"github.com/square/go-jose"
)

// Log site.
var log, Log = xlog.New("acme.responder")

// A Responder implements a challenge type.
//
// After successfully instantiating a responder, you should call Start.
//
// You should then use the return values of Validation() and
// ValidationSigningKey() to submit the challenge response.
//
// Once the challenge has been completed, as determined by polling, you must
// call Stop. If RequestDetectedChan() is non-nil, it provides a hint as to
// when polling may be fruitful.
type Responder interface {
	// Become ready to be interrogated by the ACME server.
	Start(interactor interaction.Interactor) error
开发者ID:falkbizz,项目名称:acme,代码行数:30,代码来源:responder.go

示例11: portMappingLoop

package portmap

import "net"
import "time"
import "github.com/hlandau/portmap/ssdp"
import "github.com/hlandau/portmap/upnp"
import "github.com/hlandau/portmap/natpmp"
import "github.com/hlandau/xlog"

var log, Log = xlog.New("portmap")

type mode int

const (
	modeNATPMP mode = iota
	modeUPnP
)

func (m *mapping) portMappingLoop(gwa []net.IP) {
	aborting := false
	mode := modeNATPMP
	var ok bool
	var d time.Duration
	for {
		// Already inactive (e.g. expired or was never active), so no need to do anything.
		if aborting && !m.lIsActive() {
			return
		}

		switch mode {
		case modeNATPMP:
开发者ID:hlandau,项目名称:portmap,代码行数:31,代码来源:maploop.go

示例12:

// Package redissession provides a Redis-based session store.
package redissession

import (
	"bytes"
	"encoding/gob"
	"fmt"
	"github.com/garyburd/redigo/redis"
	"github.com/hlandau/degoutils/web/session/storage"
	"github.com/hlandau/xlog"
	"github.com/satori/go.uuid"
	"time"
)

var log, Log = xlog.New("web.session.redissession")

type sess struct {
	Data     map[string]interface{}
	LastSeen time.Time
}

// Redis-backed session store configuration.
type Config struct {
	// After what period of inactivity should sessions expire?
	//
	// Default: 4 hours.
	Expiry time.Duration

	// Required. Function returning a Redis connection (e.g. from a pool). Will
	// be closed when no longer needed.
	GetConn func() (redis.Conn, error)
开发者ID:hlandau,项目名称:degoutils,代码行数:31,代码来源:redis.go

示例13: sendLoop

import "os"
import "os/exec"
import "net"
import "gopkg.in/hlandau/easymetric.v1/cexp"
import "gopkg.in/hlandau/easyconfig.v1/cflag"
import "path/filepath"
import "github.com/hlandau/xlog"
import "sync"
import "io"
import "gopkg.in/alexcesaro/quotedprintable.v3"
import "mime/multipart"
import "net/textproto"

var cEmailsSent = cexp.NewCounter("sendemail.emailsSent")

var log, Log = xlog.New("sendemail")

var (
	fg               = cflag.NewGroup(nil, "sendemail")
	smtpAddressFlag  = cflag.String(fg, "smtpaddress", "", "SMTP address (hostname[:port])")
	smtpUsernameFlag = cflag.String(fg, "smtpusername", "", "SMTP username")
	smtpPasswordFlag = cflag.String(fg, "smtppassword", "", "SMTP password")
	sendmailPathFlag = cflag.String(fg, "sendmailpath", "", "path to /usr/sbin/sendmail")
	numSendersFlag   = cflag.Int(fg, "numsenders", 2, "number of asynchronous e. mail senders")
	fromFlag         = cflag.String(fg, "from", "[email protected]", "Default from address")
)

var sendChan = make(chan *Email, 32)
var startOnce sync.Once

func sendLoop() {
开发者ID:hlandau,项目名称:degoutils,代码行数:31,代码来源:sendemail.go

示例14:

// Package opts provides miscellaneous configurable globals commonly required
// by web application servers.
package opts

import "gopkg.in/hlandau/easyconfig.v1/cflag"
import "github.com/hlandau/xlog"
import "crypto/rand"
import "crypto/hmac"
import "crypto/sha256"
import "encoding/hex"

var log, Log = xlog.New("web.opts")

// Development mode? In development mode, the application server may behave
// differently. Errors may be reported differently, assets may be reloaded
// automatically, etc.
//
// Configurable 'devmode'.
var DevMode bool

var devModeFlag = cflag.BoolVar(nil, &DevMode, "devmode", false, "Development mode?")

// Base directory. Some files may be looked for relative to this directory; templates, assets, etc.
//
// Configurable 'basedir'.
var BaseDir string

var baseDirFlag = cflag.StringVar(nil, &BaseDir, "basedir", "", "Base dir (containing assets, tpl directories, etc.)")

// Base URL. This is the canonical base URL, which will be used in e.g. e.
// mails. It should not have a trailing slash.
开发者ID:hlandau,项目名称:degoutils,代码行数:31,代码来源:opts.go

示例15: Prompt

package interaction

import (
	"fmt"
	"github.com/hlandau/xlog"
)

var log, Log = xlog.New("acme.interactor")

// Used by Auto. If this is set, only autoresponses can be used. Any challenge
// without an autoresponse fails. --batch.
var NonInteractive = false

type autoInteractor struct{}

// Interactor which automatically uses the most suitable challenge method.
var Auto Interactor = autoInteractor{}

// Used by Auto. If this is non-nil, all challenges are directed to it. There
// is no fallback if the interceptor fails. Autoresponses and NonInteractive
// take precedence over this.
var Interceptor Interactor

// Used by Auto. Do not use the Dialog mode. --stdio.
var NoDialog = false

func (autoInteractor) Prompt(c *Challenge) (*Response, error) {
	r, err := Responder.Prompt(c)
	if err == nil || c.Implicit {
		return r, err
	}
开发者ID:meyskens,项目名称:acme,代码行数:31,代码来源:auto.go


注:本文中的github.com/hlandau/xlog.New函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。