log4erl API

https://github.com/ahmednawras/log4erl/blob/master/API.txt

NOTE:
=====
Please be informed that the API below as of now is not stable and any of the functions/parameters below
may be changed without prior notice.

Furthermore, you can find appenders and their configurations in ‘Appenders_API.txt‘ file included in release.

**> log4erl:conf(File) -> ok | {error, E}
File :: string()

File is the name of the configuration file. Please check CONFIGURATION.txt for the format of this file.

**> log4erl:add_logger(Name) -> ok | {error, E}
Name :: atom() name of the logger

Example:
log4erl:add_logger(chat_logger)
This will create a new logger with name ‘chat_logger"

**> log4erl:change_log_level(Level) -> ok
log4erl:change_log_level(Logger, Level) -> ok
Level::atom() = {all, debug, info, error, warn, fatal, none}
Logger::atom()

This will change log level for default logger or named logger to the level
specified.

Example:
log4erl:change_log_level(info). %% This will change level of default logger to info
log4erl:change_log_level(test_log, warn) %% This will change level of test_log logger to warn

**> log4erl:change_level(Appender, Level) -> ok
log4erl:change_level(Logger, Appender, Level) -> ok
Logger :: atom()
Appender :: atom()
Level :: atom()

@since version 0.8.4

This will change log level for a specific appender, as opposed to change_log_level/2,3 which changes
level for all appenders in a logger.

Example:
log4erl:change_level(appender1, all).

**> log4erl:change_format(Appender, Format) -> ok
log4erl:change_format(Logger, Appender, Format) -> ok
Appender :: atom()
Logger :: atom()
Format :: string()

@since version 0.8.3

This will change the output format to the specified Format. Format is a pattern string similar to
PatternLayout in Log4j. patterns is an arbitrary string with specifiers (proceeded by ‘%‘).
Possible specifiers are below:
d - output date (2008-3-7)
j - output date (2008-03-07)
t - time (2:13:9)
T - time (02:28:01.811637)
y - year in YY format (08)
Y - year in YYYY format (2008)
M - month (2)
b - short name of month (Feb)
B - long name of month (February)
D - day
h - hour
m - minute
s - second
i - milli-seconds
l - the actual log message
I - ISO format with universal GMT time (equivilant to "%jT%TZ").
S - ISO format with local time and time zone offset
Z - timezone (+04:00)
L - log level
n - new line
% - the percentage sign (%)

Example:
log4erl:change_format(file1, "%j %T [%L] %l%n").
Will result in the following output (on log4erl:warn("hello"))

27-10-2008 15:28:59,98621 [warn] hello

**> log4erl:log(Level, Log) -> ok
Level :: atom()
Log :: string()

This will log the text Log to the default logger with level Level.

Example:
log4erl:log(warn, "Hello there").
log4erl:log(test_level, "Hello there").

**> log4erl:log(Level, Log, Data) -> ok
Level :: atom()
Log :: string()
Data :: list()

This will log the text Log to the default logger with level Level and
will use Data to format the log text.

Example:
log4erl:log(info, "received message ~p", [Msg]).

**> log4erl:log(Logger, Level, Log, Data) -> ok
Logger :: atom()
Level :: atom()
Log :: string()
Data :: list()

This will log the (Log, Data) to Logger with level Level

Example:
log4erl:log(chat_log, debug, "user entered chat text: ~p", [Chat]).

**> log4erl:Level(Log) -> ok
log4erl:Level(Log, Data) -> ok
log4erl:Level(Logger, Data) -> ok
log4erl:Level(Logger, Log, Data) -> ok

Level :: warn | info | error | fatal | debug
Logger :: atom()
Log :: string()
Data :: list()

Exmaple:
log4erl:info("This is an info msg").
log4erl:warn("Received error ~p",[Msg]).
log4erl:fatal(chat_log, "exception occured").
log4erl:debug(chat_log, "message received is ~p", [Msg]).
log4erl:error("Error").

**> log4erl:error_logger_handler() -> ok
log4erl:error_logger_handler(Mappings) -> ok
where
Mappings :: [Mapping]
Mapping :: {Elevels, level}
ELevels :: error | info_msg | warning_msg | error_report | info_report | warning_report

Mappings basically is a list of mapping between error_logger log levels and log4erl log levels.
Currently, report messages are not handled by this error_logger handler. The default Mappings are:
{error=error, info_msg=info, warning_msg=warn,
error_report=error, info_report=info,
warning_report=warn}

Example:
log4erl:error_logger_handler([{error, fatal}, {info_msg, info}]).

which treats all error messages coming from error_logger as fatal and all info_msg
messages coming from error_logger as info.

时间: 2024-11-08 23:26:08

log4erl API的相关文章

log4erl Configuration

https://github.com/ahmednawras/log4erl/blob/master/CONFIGURATION.txt Configuration Guide: ==================== TOC:====* Introduction* Loggers - Example* Appenders - common properties - file_appender - console_appender - smtp_appender - syslog_append

百度地图API实现批量地址解析

1.前言 写这篇文章的原因是最近做一个GIS项目在网上爬取了一些数据,无奈只有地址的文字信息没有坐标信息,如何把信息显现在地图上呢?很纠结啊,查看了一下百度地图API惊奇的发现百度提供了地址解析的API,然后查看了他的Demo后豁然开朗,所以动手将自己的文字信息数据进行解析坐标信息.下面开始讲解. 2.方案 (1)自己数据库中的数据 (2)百度地图API Demo <!DOCTYPE html> <html> <head> <meta http-equiv=&qu

【API】高德地图API JS实现获取坐标和回显点标记

1.搜索+选择+获取经纬度和详细地址 2.回显数据并点标记 3.实现 第一步:引入资源文件 <!--引入高德地图JSAPI --><script src="//webapi.amap.com/maps?v=1.3&key=在官网申请一个key"></script><!--引入UI组件库(1.0版本) --><script src="//webapi.amap.com/ui/1.0/main.js">

【Windows10&nbsp;IoT开发系列】API&nbsp;移植工具

原文:[Windows10 IoT开发系列]API 移植工具 Windows 10 IoT Core 中是否提供你的当前 Win32 应用程序或库所依赖的 API? 如果不提供,是否存在可使用的等效 API? 此工具可以为你回答这些问题,并协助你将你的当前 Win32 应用程序和库迁移到 Windows IoT Core. Windows 10 IoT 核心版 API 移植工具可在 ms-iot/iot-utilities github 存储库中找到.下载存储库 zip 并将 IoTAPIPor

beego应用做纯API后端如何使用jwt实现无状态权限验证

jwt是什么,可以百度下其它文章,我原来看到一个讲的详细的,现在找不到了.先简单介绍下我个人的理解,就是一个token,只不过通过加密解密的手段,能让这一串字符带有一些简单的信息.这样解密jwt后不用查数据库,最常用的例子,保存用户权限,再多层的权限,其实只用一个数字,转换成二进制,每一位代表一种权限.类似这样的使用,还有保存session的key,通过该值查session就能获取更丰富的资料,用来保存用户状态也是可以的. 下面介绍下我的一个golang项目中使用beego框架做纯API接口使用

HTML5新增Canvas标签及对应属性、API详解(基础一)

知识说明: HTML5新增的canvas标签,通过创建画布,在画布上创建任何想要的形状,下面将canvas的API以及属性做一个整理,并且附上时钟的示例,便于后期复习学习!Fighting! 一.标签原型 <canvas width=”1000” height=”1000” id=”myCanvas”> 您的浏览器版本过低,不支持HTML5新增的canvas标签. </canvas> 使用js获取该画布,并指定对象 <script> Var canvasID = doc

通过beego快速创建一个Restful风格API项目及API文档自动化(转)

通过beego快速创建一个Restful风格API项目及API文档自动化 本文演示如何快速(一分钟内,不写一行代码)的根据数据库及表创建一个Restful风格的API项目,及提供便于在线测试API的界面. 一.创建数据库及数据表(MySQL) #db--jeedev -- ---------------------------- -- Table structure for `app` -- ---------------------------- DROP TABLE IF EXISTS `a

Asp.Net MVC及Web API框架配置会碰到的几个问题及解决方案 (精髓)

前言 刚开始创建MVC与Web API的混合项目时,碰到好多问题,今天拿出来跟大家一起分享下.有朋友私信我问项目的分层及文件夹结构在我的第一篇博客中没说清楚,那么接下来我就准备从这些文件怎么分文件夹说起.问题大概有以下几点: 1.项目层的文件夹结构 2.解决MVC的Controller和Web API的Controller类名不能相同的问题 3.给MVC不同命名空间的Area的注册不同的路由 4.让Web API路由配置也支持命名空间参数 5.MVC及Web API添加身份验证及错误处理的过滤器

运行Chromium浏览器缺少google api密钥无法登录谷歌账号的解决办法

管理员身份运行CMD,然后依次输入以下三行内容: setx GOOGLE_API_KEY "AIzaSyAUoSnO_8k-3D4-fOp-CFopA_NQAkoVCLw"setx GOOGLE_DEFAULT_CLIENT_ID "6307505647-6knmr84r2pj2leudg3pp1j0h1licd6b9.apps.googleusercontent.com"setx GOOGLE_DEFAULT_CLIENT_SECRET "rbeWhXT